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

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>
主站蜘蛛池模板: 大石桥市| 三门县| 昂仁县| 黄浦区| 凌海市| 新绛县| 阿勒泰市| 平舆县| 长汀县| 吴忠市| 张掖市| 禹城市| 东乡族自治县| 恭城| 元阳县| 闸北区| 方城县| 蚌埠市| 南江县| 屏东市| 五指山市| 手游| 孙吴县| 新密市| 林周县| 霍林郭勒市| 钟祥市| 嘉禾县| 邢台市| 莲花县| 莆田市| 陆丰市| 澄江县| 阿克苏市| 伊金霍洛旗| 抚松县| 洞头县| 吉安县| 普陀区| 张家口市| 阿尔山市|