循環(huán)
-
循環(huán)數(shù)組
- html
<div id="app"> <ol> <li v-for="item in list">{{item.content}}</li> </ol> </div>
- js
<script> // 初始化數(shù)據(jù) window.onload = function () { var vue = new Vue({ el: '#app', data: { list: [{ content: '內(nèi)容1' }, { content: '內(nèi)容2' }, { content: '內(nèi)容3' }, ] } }); }; </script>
-
循環(huán)對象
- html
<div id="app"> <ul> <li v-for="(item,key) in json">{{item}}.{{key}}</li> </ul> </div>
- js
<script> // 初始化數(shù)據(jù) window.onload = function () { // vue var vueApp = new Vue({ el: '#app', data: { json: { a: 'A', b: 'B', c: 'C' } } }); }; </script>