Ant-design-vue: Select选择器的使用

Created on 14 Jun 2018  ·  7Comments  ·  Source: vueComponent/ant-design-vue

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

描述

现在的select选择器使用起来感觉有点冗余,是否可以简化一下?

现在

<a-select v-model="value">
    <a-select-option v-for="option of options"
        :value="option.value" :key="option.value">{{option.label}}</a-select-option>
</a-select>

可以这样?

<a-select v-model="value" :data-source="options"></a-select>

What is actually happening?

...


...

Select Feature Request

Most helpful comment

后续两种方式均会保留并且dataSource拥有更高的优先级,如需要灵活性可继续使用a-select-option

All 7 comments

👌 后期会考虑,你也可以给我们提pr

如果用了你简化了的版本,我怎样才可以改变select-option里面的内容
现在的是比较好,一看便了解怎样用
:datasource 当你看见时,其实不知怎样用,要看doc才会了解
a-select-option 根本就是select里的option,一看便懂了

@jasonc08

  1. 你为什么需要改变option里的内容?其实对于使用者来说并不关心option部分;
  2. 每个组件都需要看doc的,这里只要约定好value和label两个属性即可,就像table的数据约定了title和dataIndex;
  3. doc只需看一次,一劳永逸,你这样每次都得多写这么多代码,不够简洁

@tangjinzhou 不好意思啊,对jsx语法不是很熟悉,看了下源码,select组件的代码结构有点复杂,不知道怎么下手[捂脸]。只是建议,还好并不影响使用。

感觉现在的写法更加灵活,也方便订制。

后续两种方式均会保留并且dataSource拥有更高的优先级,如需要灵活性可继续使用a-select-option

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

Was this page helpful?
0 / 5 - 0 ratings