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

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>
主站蜘蛛池模板: 开原市| 尉氏县| 上思县| 大厂| 景谷| 交口县| 泊头市| 铁岭县| 阿城市| 左云县| 加查县| 安泽县| 唐山市| 祥云县| 西昌市| 浮梁县| 新绛县| 苏州市| 闸北区| 瑞昌市| 刚察县| 长沙县| 延川县| 公主岭市| 来凤县| 镇雄县| 方城县| 镇原县| 高青县| 永平县| 治多县| 会同县| 宁国市| 潞西市| 安宁市| 宝清县| 崇明县| 陕西省| 萨迦县| 德令哈市| 巴马|