今天在使用IVIEW的时候要设置默认选中项,文档如下:
给 data 项设置特殊 key _checked: true
可以默认选中当前项。
给 data 项设置特殊 key _disabled: true
可以禁止选择当前项。
代码如下:
<Table ref="selection" :columns="dispose" :data="optionalList" @on-selection-change="changeSelect"></Table>
举例设置第一条数据,发现使用以下方法设置都是无效的
this.optionalList[0].isCheck = true;
this.optionalList[0]._checked = true;
this.optionalList[0]._disabled = true;
后使用以下代码设置成功,注(给Table 添加 ref),这里设置的为selection
this.$refs.selection.$refs.tbody.objData[i]._isChecked = false // 设置已勾选项为空或者勾选true