-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
untriagedneed to sortneed to sort
Description
描述错误
文档需要补充一下这个内容:
n-cascader如果要支持remote的话,需要在option中给到isLeaf = false
否则无法on-load函数是无法被调用的
复现步骤
- 设置n-cacscader为remote,且给到on-load函数
- 设置n-cascader的option为:
[{label:"label", value:"value", children:[]}]
- 选择级联项目的时候,无法调用到on-load函数
我一开始是没有给到children:[]
的,以为如果没有children的话,能够触发onLoad
结果打开的时候右边箭头也不展示了,无法打开下级页面。
后来我又想是不是因为我没给到children,触发onLoad的逻辑可能是判断children是否为空数组?
然后我尝试给到children:[],结果确实是打开下级页面了,但下级页面是空的,而且也不会调用到on-load函数。
后来我又仔细看了一下demo,发现option中有一个isLeaf,设置上isLeaf = false之后,on-load函数能够被调用了🤷♂️
哦吼,因为这个问题,一下午没了🤷♂️
我原本是以为如果children为undefined或者null时,就会触发onLoad函数的,后来以为children为[]时就会触发onLoad函数,没想到要isLeaf为false才会触发。
但是isLeaf在文档里没有🤷♂️
希望作者能够完善一下文档,在文档里没看到跟isLeaf相关的描述
另外问一嘴,源码逻辑里为啥没看到类似下面这样的代码咧?如果有这样的代码我也能翻出原因来😂
if (!isLeaf && onLoad) {
onLoad(option)
}
最小复现链接
系统信息
-
使用的包管理器
yarn
验证
xhwgood
Metadata
Metadata
Assignees
Labels
untriagedneed to sortneed to sort