- 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>
推薦閱讀
- HornetQ Messaging Developer’s Guide
- Java高手真經(高級編程卷):Java Web高級開發技術
- 羅克韋爾ControlLogix系統應用技術
- VMware vSphere 6.7虛擬化架構實戰指南
- Lua程序設計(第4版)
- Windows Forensics Cookbook
- Microsoft System Center Orchestrator 2012 R2 Essentials
- MATLAB 2020從入門到精通
- Lighttpd源碼分析
- 圖數據庫實戰
- GitHub入門與實踐
- Puppet:Mastering Infrastructure Automation
- LabVIEW數據采集
- Building UIs with Wijmo
- 打造流暢的Android App