Skip to content

CheckboxGroup 的 label slot 被 option.label 覆盖了 #1807

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

Closed
1 task done
EmiyaYang opened this issue Feb 20, 2020 · 3 comments
Closed
1 task done

CheckboxGroup 的 label slot 被 option.label 覆盖了 #1807

EmiyaYang opened this issue Feb 20, 2020 · 3 comments
Labels

Comments

@EmiyaYang
Copy link

EmiyaYang commented Feb 20, 2020

  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

1.4.11

Environment

mac chrome

Reproduction link

https://github.com/vueComponent/ant-design-vue

Steps to reproduce

直接看源码

// lib/checkbox/Group.js
export default {
  ...
  methods: {
    ...
    getOptions: function getOptions() {
      var options = this.options,
      $scopedSlots = this.$scopedSlots;

      return options.map(function (option) {
        if (typeof option === 'string') {
        return {
          label: option,
          value: option
        };
        }
        var label = option.label;
        if (label === undefined && $scopedSlots.label) {
          label = $scopedSlots.label(option);
        }
        return (0, _extends3['default'])({}, option, { label: label });
      });
    }
  }
}

What is expected?

this.$scopedSlots.label 的优先级应大于 option.label. 这样在就能在 slot-scope 里面拿到 label 值加以改造.

What is actually happening?

this.$scopedSlots.label 被 option.label 覆盖, 不能基于 label 字段进行改造, 用起来有些反直觉.

Additional comment

或者 label 支持提供一个 customRender, 这样也不用费事用 slot 了.
若无计划调整, 也应在文档相应处进行注明.

@tangjinzhou
Copy link
Member

options: [{value: 'a'}]

这样配置就可以了

@EmiyaYang
Copy link
Author

@tangjinzhou 我知道这样配置ok, 只是觉得这个优先级有些反直觉. 或说文档看不出来需要到源码才能找到.

建议文档注明这一点, 提示: slot="label" slot-scope="option" 定制的 label 会被 option.label 覆盖.

@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 Feb 21, 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

2 participants