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

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>
主站蜘蛛池模板: 蒙阴县| 宜都市| 衡水市| 海南省| 稷山县| 东莞市| 楚雄市| 宕昌县| 科尔| 清水县| 双江| 武冈市| 务川| 准格尔旗| 昆山市| 全州县| 沾化县| 五莲县| 达尔| 昌平区| 吴川市| 三都| 隆子县| 沾益县| 镇沅| 宣化县| 台东县| 房产| 云梦县| 甘孜县| 四川省| 山西省| 莒南县| 太康县| 朝阳区| 新干县| 德阳市| 原平市| 绥宁县| 承德市| 临高县|