data: function(){
return {
fieldVal:""
}
},
mounted(){
this.fieldVal = this.value;
},
// 参数
props: {
// 初始化值
value: {
type: [String,Array],
default:""
},
// 字段属性
field: {
type: Object,
default: () => {
return {};
}
}
},
// 模板
template: `
<i-select v-model="fieldVal" filterable class="bh-select" :placeholder="field.field_tips?field.field_tips:'请选择'" :disabled="(field['privilege']&8)>0" clearable transfer transfer-class-name="bh-select-down-transfer" @on-change="changeSelect">
<i-option :value="item.key" v-for="(item,index) in field['data']" :key="'select_'+index">{{item.name}}</i-option>
</i-select>
解决:这里v-model="fieldVal" 改成v-model="value"
props 父组件的值变更会触发子组件更新 这边了解一下组件更新的必要条件