vue v-model 绑定动态变量

data() {
return {
search: { //查询参数
keyword: "",

productSpec:""
},
tagSearchModel: {},

}

 

//设置属性值

reponse.data.FObject.forEach(item => {


this.$set(this.tagSearchModel, "line_" + item.FTagID, "");
});

 

Html上使用:

<el-form-item :label="item.FTagName" v-for="(item,index) in basicData.tagList">
<el-autocomplete v-model="tagSearchModel['line_' + item.FTagID]"
:fetch-suggestions="((queryString,cb)=>{querySearchAsync(queryString,cb,item)})"
placeholder="请输入内容"
:trigger-on-focus="false"
@select="handleSelect(item.FTagName,$event)">
<el-button slot="append" icon="el-icon-search" @click="openSelectDialog(item,'帘身')"></el-button>
</el-autocomplete>
</el-form-item>

 

//打印看看是否动态绑定了

 // alert(eval("this.tagSearchModel.line_" + 3041));

 

posted @ 2020-04-26 21:08  随碟附送520  阅读(7645)  评论(1编辑  收藏  举报