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

Directives

Similar to Angular, we can add functionality to our templates by using directives. These are special properties we add to HTML tags starting with thev-prefix.

Say we have an array of data. We can render this data to the page as sequential HTML elements by using thev-for directive:

<p id="app">
  <h3>Grocery list</h3>
  <ul>
    <li v-for="grocery in groceries">{{ grocery }}</li>
  </ul>
</p>
<script>
  var app = new Vue({
    el: '#app',
    data: {
      groceries: [ 'Bread', 'Milk' ]
    }
  });
</script>

The preceding code renders as follows:

<p id="app">
  <h3>Grocery list</h3>
  <ul>
    <li>Bread</li>
    <li>Milk</li>
  </ul>
</p>
主站蜘蛛池模板: 田阳县| 峨边| 陆丰市| 土默特左旗| 盐津县| 蓝田县| 怀化市| 新安县| 定州市| 德钦县| 普陀区| 图木舒克市| 江安县| 宾川县| 临洮县| 宜都市| 勐海县| 商洛市| 固原市| 定西市| 桑日县| 盘锦市| 松桃| 新沂市| 阳江市| 长治县| 缙云县| 福海县| 新泰市| 莱州市| 临猗县| 长阳| 荔浦县| 大竹县| 石嘴山市| 黔西县| 三穗县| 无极县| 兴安盟| 罗城| 阿坝县|