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

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>
主站蜘蛛池模板: 常州市| 定安县| 横峰县| 宁蒗| 富源县| 聊城市| 红桥区| 蒙山县| 龙泉市| 怀仁县| 聂荣县| 松原市| 台中市| 祁东县| 类乌齐县| 延川县| 新宁县| 遵义县| 读书| 济阳县| 仙桃市| 扎囊县| 玉林市| 阜平县| 民权县| 海南省| 澳门| 红河县| 花莲县| 开远市| 湄潭县| 临高县| 天台县| 昌黎县| 龙陵县| 顺昌县| 松滋市| 靖宇县| 尉犁县| 济宁市| 嘉荫县|