发布于 5年前
vue多个json人名如何逗号分隔?
<script src="//unpkg.com/vue/dist/vue.js"></script>
<div id="app">
<template>
<span v-for="(item,index) in participant">
{{
index == participant.length-1 && item.name || (item.name + ',')
}}
</span>
</template>
</div>
var Main = {
data () {
return {
participant:[{
name:'张三'
},{
name:'李四'
},{
name:'王五'
},{
name:'赵六'
}]
};
}
}
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')
输出:张三, 李四, 王五, 赵六