点击编辑按钮会初始化编辑的内容,但是打开之后select组件的值并没有默认选中,是为什么?
代码如下:
<FormItem :label='$t("dictionary_type")' prop="type_id">
<Select v-model="dictionaryItem.type_id">
<Option v-for="dicType in dicTypes" :value='dicType.id' :key='dicType.id'>{{ dicType.dic_name }}</Option>
</Select>
</FormItem>
点击编辑时会给其赋值:
open (row) {
let _this = this;
_this.dictionaryItemId = row.id;
_this.dictionaryItem.type_id = row.type_id;
_this.dictionaryItem.item_name = row.item_name;
_this.dictionaryItem.item_value = row.item_value;
_this.dictionaryItem.sort = parseInt(row.sort);
_this.dictionaryItem.comment = row.comment;
_this.showModal = true;
}
打开之后如下图
有人说检查检查dictionaryItem.type_id是否全等value,这个怎么检查?
1.检查一下row.type_id是否有值
2.如果row.type_id有值是否符合dicTypes其中一项的id。
你可以在这个方法里面打印一下,检测一下上面两项。