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

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>
主站蜘蛛池模板: 遵义县| 定州市| 永安市| 鄂托克前旗| 耒阳市| 齐齐哈尔市| 丰台区| 隆回县| 定襄县| 广宁县| 麻阳| 金溪县| 文山县| 安宁市| 海城市| 江北区| 四子王旗| 水富县| 中卫市| 新乡县| 玛曲县| 焦作市| 贺州市| 赤城县| 禹州市| 祁东县| 三台县| 资阳市| 双鸭山市| 布拖县| 丰台区| 子洲县| 济宁市| 阿克苏市| 宿迁市| 扶沟县| 赤峰市| 甘肃省| 永州市| 新民市| 益阳市|