<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>vue标签内循环数据逗号分隔</title> <script src="http://unpkg.com/vue/dist/vue.js"></script> </head> <body> <div id="app"> <template> <span v-for="(item,index) in nameData"> {{ index == nameData.length-1 && item.name || (item.name + ',') }} </span> </template> </div> <script> var Main = { data() { return { nameData: [ { name: '张三' }, { name: '李四' }, { name: '王五' }, { name: '赵六' } ] }; } } var Ctor = Vue.extend(Main) new Ctor().$mount('#app') </script> </body> </html>