vue指令之v-for

main.js:

var app = new Vue({
    el: "#app",
    data: {
        foodList: [{
            name: "",
            price: 10,
            discount: .5
        },{
            name: "",
            price: 8,
            discount: .8
        },{
            name: "",
            price: 15,
        }]
    }
});

index.html:

html>
lang="en">

    charset="UTF-8">
    </span>Title<span style="color:#e8bf6a;">



id="app">
  • v-for="food in foodList">{{food.name}}: {{food.discount?food.price*food.discount:food.price}}


你可能感兴趣的:(vue)