好家伙,
<body> <div id="app"> <p v-if="flag">这是v-if控制的</p> <p v-show="flag">这是v-show控制的</p> <p v-if="false">这是v-if控制的</p> <p v-show="false">这是v-show控制的</p> </div> <script src="https://cdn.jsdelivr.net/npm/vue@2"></script> <script> const vm = new Vue({ el:'#app', data:{ flag:true, false:false, count:1, }, }) </script> </body>
<div id="app"> <div v-if="type ==='A'">1111</div> <div v-else-if="type ==='B'">2222</div> <div v-else-if="type ==='C'">3333</div> <div v-else>4444</div> </div>
<body> <div id="app"> <table> <thead> <th>索引</th> <th>id</th> <th>姓名</th> </thead> <tbody> <tr v-for="item in list" > <td>{{ item.id }}</td> <td>{{ item.id }}</td> <td>{{ item.name }}</td> </tr> </tbody> </table> </div> <script src="https://cdn.jsdelivr.net/npm/vue@2"></script> <script> const vm = new Vue({ el:'#app', data:{ list:[ { id: 1,name: 'panghu'}, { id: 2,name: 'fattiger'}, { id: 3,name: '张三'}, ] }, methods:{ } }) </script> </body>
That's all