element [Bug Report] el-cascader 在@change中修改v-model绑定的值,会报Cannot read property 'level' of null

ukxgm1gy  于 2022-10-26  发布在  其他
关注(0)|答案(2)|浏览(300)

Element UI version

0.1.0

OS/Browsers version

Chrome 84.0.4147.105

Vue version

2.6.11

https://codepen.io/thj2/pen/yLOerdR

Steps to reproduce

(上面Repository Version 只有0.1.0这一个选项) 实际2.13.0

  1. 点击全部
  2. 点击其他选项就会报错
    3.不能删除

What is Expected?

版本 element-ui 2.10.0 可以看到
修改 element-ui->lib->casader-panel.js 下
handleExpand: function handleExpand(node, silent) {}
在此方法中判断node是否为空

if(!node)return

不知道什么原因我在@chang方法中二次修改后node为空

在1294行 var nodes = activePath.map(function (node) {
return _this2.getNodeByValue(node.getValue());
});
nodes为 []导致后面的错误

What is actually happening?

统一报错(TypeError: Cannot read property 'level' of null)
版本element-ui 2.10.0是可以的,版本2.13.0及以上不行(其他未测试)

xwbd5t1u

xwbd5t1u1#

  1. 给 cascader绑定 key,切换前更新 key值重新渲染
  2. 切换前,将 cascader原来绑定数据清空

通过这样的操作,目前看来是可以的

zbq4xfa0

zbq4xfa02#

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

相关问题