 
                        vue组件,把字符串切割为数组 然后循环输出结果报错
想得到下面这样的数据
#1岁-2岁 #早餐 #快手
var test = "1岁-2岁,早餐,快手";
<cook-tag :tags="test" />
Vue.component("cook-tag", {
    template: "<span class='tag-item' v-for='item in list'>#{{item}}</span>",
    data() {
        return {
            list:[],
        }
    },
    props: ["tags"],
    created(){
        this.list = this.tags.split(",") || [];
    },
})Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
组件模板只能有一个父元素,需要把span包起来