|  | 
 
| 
2 J! R) }* W  n8 A
x
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!您需要 登录 才可以下载或查看,没有账号?注册 
  
 - L6 z7 K0 H# ?9 o# ?7 I+ Q0 a) ?  _- r  y" G
 <!DOCTYPE html>
 4 T% E% d! ]1 H9 ^<html lang="en">
 % i6 ]0 ~: Q0 Q" [+ _+ f5 ~: Q+ Y    <head>
 0 A. A) \1 f0 J9 ~' k" l        <meta charset="UTF-8">
 , r7 Q2 |6 @- _5 {4 x" V/ `        <title>Vue JS V-show, v-for,v-if</title>
 g5 y7 n3 U" y1 P" n3 g6 ~        <script src='./vue.js'></script>
 $ f' U  j0 S/ Q2 j8 i0 n$ L$ I- R    </head>
 ! l: d0 c, f  ]    <body>3 q; F6 R! I6 H/ |+ I+ r
 <div id="root">5 D; ]. [( M  w# g
 <!-- v-if delete the dom
 " S. a  H2 N( [  E6 `2 |/ U            v-show just set the display:none -->
 ( [  n3 `3 G6 c           <div v-if="show">hello plmhome</div>
 , t* R' \0 A) h/ Y           <button @click="toggle">toggle to display</button># m. ~6 {6 S" x8 p
 9 g5 ]3 w: _. D+ T
 <ul>
 5 M  Q5 x0 t) o                <li v-for="(item,index) in list" :key="index">{{item}}</li>
 4 D( p5 ?5 Q) `; F* k, P- d            </ul>3 M* F( d/ ~( \, g' d; k1 U
 / `% n' E: h  c, Z: w/ _
 </div>4 |8 X- I& s# W& M& W( ~
 $ R2 N" Q8 T% t- ]0 R! J+ z7 j
 
 ) h- l6 V% t7 a0 V/ q6 W        <script>
 1 b7 o/ b# l6 ?2 Y. v+ G5 p6 Q        new Vue({
 " E* \/ C4 F3 W' S+ S            el: "#root",
 - C9 ?' D7 T4 {# n) e! P            data:{. j4 g9 Y3 b' A9 S+ \
 show: true,
 C/ s4 Q6 U- G) u                list:['plm','home','I','love','you']
 " s" T/ Z+ L# u6 ?. u: D4 z            },  {$ A6 r9 \  l! B4 g7 u4 y& L# n
 methods:{* E1 C. M. z. K0 H- T. T! V  W# c
 toggle:function(){1 k# f8 n; u4 r: T) E- ^' Y( S: f
 this.show = !this.show;+ V, m& R4 g7 H; }$ f/ h% x* x
 }
 ( x3 V3 S/ z; h, d            }
 0 [2 f+ x& G1 z. Y        })4 t) u5 q" L4 `! R7 `+ m. B# h- @
 </script>$ c# s; v' ~' |7 s7 o+ _, H
 </body>; h: `6 n) w) b1 D
 </html>
 * T8 u' c" M7 A& p* A' i, w& u) |  k$ I, {- E, r* r: X9 C1 ]
 
 3 Z9 M  C" I( A8 J; {% x
 | 
 |