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

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>
主站蜘蛛池模板: 泗洪县| 西畴县| 乐都县| 绥中县| 行唐县| 黑水县| 宜丰县| 平遥县| 洱源县| 万源市| 禹州市| 清苑县| 璧山县| 东港市| 合作市| 阜新市| 郓城县| 盐亭县| 文安县| 合川市| 油尖旺区| 株洲市| 宜川县| 临澧县| 垦利县| 灵川县| 阿坝县| 高淳县| 佛山市| 高密市| 沧州市| 嵩明县| 永丰县| 石渠县| 饶平县| 龙门县| 黎城县| 杂多县| 古蔺县| 龙门县| 无棣县|