VUE(v-if,v-show,v-for)

mac2024-04-09  25

<!DOCTYPE html> <html>     <head>         <meta charset="utf-8" />         <title></title>         <script src="./vue.js"></script>     </head>     <body>         <div id="root">             <div v-show="show">123</div>             <div v-if="!show">456</div>             <button @click="change">点击</button>   <!-- 点击按钮会出现123/456切换成456/123 -->             <ul>                 <li v-for="(item,index) of list":key="index">{{item}}</li>     <!-- v-for -->             </ul>         </div>          <script>             new Vue({                 el:"#root",                 data:{                       show:true,                     list:[1,2,3]                 },             methods:{                 change:function(){                     this.show=!this.show;                 }             }             })         </script>     </body> </html>

最新回复(0)