Vue之条件渲染
作者:互联网
1 <!DOCTYPE html> 2 <html lang="en"> 3 4 <head> 5 <meta charset="UTF-8"> 6 <meta http-equiv="X-UA-Compatible" content="IE=edge"> 7 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 8 <title>条件渲染</title> 9 </head> 10 11 <body> 12 <div id="div"> 13 <!-- 判断num的值对3取余,余数为0显示div1,余数是1显示div2,余数为2显示div3 --> 14 <div v-if="num % 3 == 0">div1</div> 15 <div v-else-if="num % 3 == 1">div2</div> 16 <div v-else="num % 3 == 2">div3</div> 17 18 <div v-show="flag">div4</div> 19 </div> 20 </body> 21 <script src="../js/vue.js"></script> 22 <script> 23 new Vue({ 24 25 el: "#div", 26 data: { 27 num: 1, 28 flag: true 29 } 30 }); 31 </script> 32 33 </html>
标签:el,Vue,渲染,num,条件,div4,div3 来源: https://www.cnblogs.com/dss-99/p/15224874.html