javascript - vue component data loop
天蓬老师
天蓬老师 2017-05-18 11:02:33
0
1
550

vue component, cuts the string into an array and then loops the output results and reports an error

I want to get the following data

#1岁-2岁 #breakfast #快手

var test = "1 year old-2 years old, breakfast, fast hand";

<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(",") || [];
    },
})
天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(1)
世界只因有你

Component template can only have one parent element, and span needs to be wrapped

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!