iview 的select组件编辑回显的时候赋值没有显示

点击编辑按钮会初始化编辑的内容,但是打开之后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,这个怎么检查?

阅读 4.3k
1 个回答

1.检查一下row.type_id是否有值
2.如果row.type_id有值是否符合dicTypes其中一项的id。

你可以在这个方法里面打印一下,检测一下上面两项。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题