首页 > 其他 > 详细

v-for指令

时间:2018-01-30 18:10:55      阅读:233      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <ul>
        <li v-for="food in foodList">
            {{food.name}}:¥{{food.discount ? food.price*food.discount : food.price }}
        </li>
    </ul>
</div>

<script src="../lib/vue.js"></script>
<script src="js/main.js"></script>
</body>
</html>
var app = new Vue({
    el:"#app",
    data:{
        // foodList:["葱","姜","蒜"],
        foodList:[
            {
                name:"葱",
                price:10,
                discount:.8
            },
            {
                name:"姜",
                price:8,
                discount:.6
            },
            {
                name:"蒜",
                price:6,

            }
        ]
    }
})

 

v-for指令

原文:https://www.cnblogs.com/52-qq/p/8386245.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!