- Full-Stack Vue.js 2 and Laravel 5
- Anthony Gore
- 80字
- 2021-07-02 19:57:13
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>
推薦閱讀
- OpenDaylight Cookbook
- iOS開發實戰:從零基礎到App Store上架
- 從0到1:HTML+CSS快速上手
- Mastering Ubuntu Server
- Amazon S3 Cookbook
- H5頁面設計:Mugeda版(微課版)
- Spring Boot企業級項目開發實戰
- 基于SpringBoot實現:Java分布式中間件開發入門與實戰
- Apache Camel Developer's Cookbook
- GitHub入門與實踐
- Java程序設計與項目案例教程
- Python函數式編程(第2版)
- Mastering Embedded Linux Programming
- Access數據庫應用教程(2010版)
- PHP 7 Programming Blueprints