官术网_书友最值得收藏!

Example: v-if

v-ifwill conditionally render an element if its value is a truthy expression. In the following case,v-ifwill remove/insert thepelement depending on themyvalvalue:

<p id="app">
  <p v-if="myval">Hello Vue</p>
</p>
<script>
  var app = new Vue({
    el: '#app',
    data: {
      myval: true
    }
  });
</script>

Will renders as:

<p id="app">
  <p>Hello Vue</p>
</p>

If we add a consecutive element with thev-elsedirective (a special directive that requires no value), it will be symmetrically removed/inserted asmyvalchanges:

<p v-if="myval">Hello Vue</p>
<p v-else>Goodbye Vue</p>
主站蜘蛛池模板: 凤冈县| 阳西县| 深水埗区| 靖远县| 新邵县| 突泉县| 乐山市| 宁国市| 久治县| 浑源县| 临清市| 佳木斯市| 衡东县| 廉江市| 大英县| 东台市| 余姚市| 姜堰市| 陆丰市| 通山县| 龙海市| 兴隆县| 新建县| 河南省| 阿荣旗| 藁城市| 平谷区| 峨边| 轮台县| 梧州市| 陆河县| 普兰店市| 神农架林区| 陆良县| 济宁市| 塔城市| 德州市| 凤冈县| 英吉沙县| 阳信县| 蓝田县|