Description
- I have searched the issues of this repository and believe that this is not a duplicate.
Version
1.1.6
Environment
vue2.5.x any OS
Reproduction link
https://tangjinzhou.gitee.io/ant-design-vue/components/tree-cn/#components-tree-demo-directory
Steps to reproduce
https://tangjinzhou.gitee.io/ant-design-vue/components/tree-cn/#components-tree-demo-directory
自定义图标 # 可以针对不同的节点定制图标。 ==> 这个selected 出来有问题,在官网上就不能根据点击状态进行图标切换
What is expected?
<template slot="custom" slot-scope="{selected}">
<a-icon :type="selected ? 'frown':'frown-o'" />
</template>
frown到frown-o的切换, 应该能够根据selected 起作用
What is actually happening?
看了一下是antd.js renderSelector调用生成自定义函数里面ref指向的是渲染函数,而非当前的item
fn: function(ref) { //<== 这个函数实际上会被renderSelector压入两个参数func 和item
//var item =arguments[1]; 实际操作的对象在第二个参数,但是ref指向的是func, 应该指向item就对了
return [_vm._v( _c('a-icon', { attrs: {"type": ref.selected ? 'frown' : 'frown-o'}})]
}
改成
<template slot="custom" slot-scope="ref,slotProps">
<a-icon :type="slotProps.selected ? 'frown':'frown-o'" />
</template>
可work