美文网首页
2018-09-10第一节vue

2018-09-10第一节vue

作者: 如履薄冰Zz | 来源:发表于2018-09-11 14:33 被阅读0次

v-for循环
1,用vue输出内容

<div id=“abc”>
{{msg}}
</div>
<script type="text/javascript" src="js/vue.js"></script>
<script>
            new Vue({
                el:'#adc',   //element元素
                data:{   //写数据
                    msg:'hello 123456789',
 }
 })
</script>

2,用v-for循环数组或对象

<div id="adc">
            {{msg}}
            <ul>
                <li v-for="v in arr">{{v}}</li>
            </ul>
            <ul>
                <li v-for="(ab,index) in obj">{{index}}-{{ab}}</li>
            </ul>
</div>
<script type="text/javascript" src="js/vue.js"></script>
        <script>
            new Vue({
                el:'#adc',
                data:{
                    msg:'hello 123456789',
                    arr:[1,2,3],
                    obj:{name:'adc',age:18},
}
})
</script>

3,用v-for循环输出数组对象

<div id="adc">
<ul>
                <li v-for="(cai,index) in arrs">{{cai.num}}{{cai.name}}{{cai.price}}</li>
            </ul>
            <table border="1" cellspacing="0">
                <tr>
                    <th>顺序</th>
                    <th>菜名</th>
                    <th>价格</th>
                </tr>
                <tr v-for="cai in arrs">
                <td>{{index+1}}</td>
                <td>{{cai.name}}</td>
                <td>{{cai.price}}</td>
                </tr>
            </table>
        </div>
</script>
<script type="text/javascript" src="js/vue.js"></script>
        <script>
            new Vue({
                el:'#adc',
                data:{
                    arrs:[
                    {name:'铁板孙金城',price:60},
                    {name:'红烧孙金城',price:98},
                    {name:'脆皮孙金城',price:54},
                    {name:'凉拌孙金城',price:12},
                    {name:'清蒸孙金城',price:52},
                    {name:'油炸孙金城',price:49},
                    { name:'大饼卷孙金城',price:34}
                    
                    ]
                }
            })
        </script>
    

相关文章

  • Vue-01-xiaoming

    2018-09-10 对于Vue的初次了解呢,也许很惶恐,也许很高大上,但是在学习中,我希望把枯燥的Vue...

  • 2018-09-10

    2018-09-10 戴师傅 2018-09-10 2018-09-10 20:32 打开App (稻盛哲学学习会...

  • 2018-09-10第一节vue

    v-for循环1,用vue输出内容 2,用v-for循环数组或对象 3,用v-for循环输出数组对象

  • Vue-01-xiaoming

    2018-09-10 今天是分班的第一天,也认识了我的教员小谢同学。 对于Vue的初次了解呢,也许很惶恐,也许很高...

  • 公告(2018-09-10更新)最近已经回归工作几个月了,发现很

    文丨lyh165发布时间:2018-09-10 (周一 广州/晴)最后更新时间:2018-09-10 (周一 广州...

  • vue

    第一节 vue:读音: v-u-eview vue和angular区别?vue——简单、易学指令以 v-xxx一片...

  • 2018-09-13

    第一节 new Vue({el:'#itany',data:{arr:[{num:'1',name:'tom',o...

  • 2018-09-10 Vue框架

    new Vue(){ //el是element的简写 el后面跟的是选择器 el:'#app', data...

  • 2018-09-11

    vue.js第一节9月10日vue.js基础、v-for循环、v-modv-el双向绑定、v-on事件、table...

  • 2018-09-11

    第一节 {{val}}---{{inp}} 第二节 vue-for循环 第三节

网友评论

      本文标题:2018-09-10第一节vue

      本文链接:https://www.haomeiwen.com/subject/qdssgftx.html