码迷,mamicode.com
首页 > 其他好文 > 详细

Vue学习之vue中的v-if,v-show,v-for

时间:2019-01-06 20:45:02      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:handle   script   method   dog   content   one   .sh   fun   http   

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>vue</title>
    <script src="vue.js"></script>
</head>
<body>

    <!-- vue中的v-if,v-show,v-for
        v-if:
        v-show:display:none/block
        v-for:
     -->

    <div id="root">
        <div v-if="show">hello dog</div>
        <button @click="handleClick">toggle</button>
        <ul>
            <li v-for="(item, index) of list" :key="index">{{item}}</li>
        </ul>
    </div>
    
    <script>
        new Vue({
            el:"#root",
            data:{
                show: true,
                list: [1,2,3]
            },
            methods: {
                handleClick: function() {
                    this.show = !this.show
                }
            }
        })
    </script>
</body>
</html>

Vue学习之vue中的v-if,v-show,v-for

标签:handle   script   method   dog   content   one   .sh   fun   http   

原文地址:https://www.cnblogs.com/twodoge/p/10230143.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!