我使用的是vue-tags-input,我想设置从服务器应用程序接口获得的默认值。现在我的值看起来不像标签,它看起来像一个文本,如果我有多个值,看起来像“测试test2",就像一个输入。我想直接作为标签插入。
<div>
<vue-tags-input
v-model="tagName"
:tagName="tagName"
:allow-edit-tags="true"
:autocomplete-items="items"
:autocomplete-filter-duplicates="false"
class="tags-input"
@tags-changed="newTags => tags = newTags"
/>
</div>
props:['customer_names'],
data() {
return {
tagName: '',
tags: [],
};
},
mounted(){
this.tagName = this.customer_names[0].name
this.tagName += this.customer_names[1].name
},
发布于 2019-12-05 08:29:03
我找到了一个方法。
在我的div中,我用:tags="tags"
替换了:tagName="tagName"
,并且:
mounted(){
var result = this.data_from_api.map(item => ({ "text": item.name,"tiClasses":["ti-valid"] }));
this.tags = result;
},
https://stackoverflow.com/questions/59190761
复制