<ul>
<li v-for="item in array">{{item.city}}</li>
</ul>
const dataObj = {
array:[
{
city:‘beijing‘
},{
city: ‘fuzhou‘
},{
city: ‘shanghai‘
}
]
};
<ul>
<li v-for="(item,index) in array">{{index}}.{{item.city}}</li>
</ul>
<ul>
<li v-for="(value,name,key) in object">{{key}}.{{name}}.{{value}}</li>
</ul>
const dataObj = {
object : {
name:‘gui‘,
key:‘123‘,
value:‘321‘
}
};
<ul>
<template v-for="item in array">
<li>{{item.city}}</li>
<li>.....</li>
</template>
</ul>
<div v-for="i in 10">{{i}}</div>
<template v-if="flag">
<li v-for="item in array">{{item.city}}</li>
</template>
<ul>
<li v-for="item in arrayCity">{{item.city}}</li>
</ul>
const app = new Vue({
el: ‘#app‘,
data: dataObj,
computed: {
arrayCity(){
this.array.splice(1,1);
return this.array;
}
},
methods: {}
});
原文:https://www.cnblogs.com/keacua/p/15251257.html