Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

官网的tree控件例子,就不能根据点击状态进行图标切换 #223

Closed
1 task
54yuri opened this issue Oct 16, 2018 · 3 comments
Closed
1 task
Labels

Comments

@54yuri
Copy link

54yuri commented Oct 16, 2018

  • 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

@tangjinzhou
Copy link
Member

下个版本会修复参数顺序错误问题 感谢反馈

@yiliang114
Copy link
Contributor

@tangjinzhou 这问题官网又出现了

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants