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

select value 为object时 怎么初始化默认项? #1780

Closed
PanJiaChen opened this issue Dec 15, 2016 · 5 comments
Closed

select value 为object时 怎么初始化默认项? #1780

PanJiaChen opened this issue Dec 15, 2016 · 5 comments

Comments

@PanJiaChen
Copy link
Contributor

demo:http://jsfiddle.net/vcgftLvn/9/

@Leopoldthecoder
Copy link
Contributor

你需要确保引用的是同一个对象:http://jsfiddle.net/leopoldthecuber/vcgftLvn/10/

@PanJiaChen
Copy link
Contributor Author

@Leopoldthecoder 如果是远程搜索 搜索怎么保证同一个对象?

@Leopoldthecoder
Copy link
Contributor

那么目前是无法做到的。因为对于一个没有存在于 options 中的 value,Select 是不知道需要把 value 的哪个字段显示出来的(所以你看到的是空白)。

如果 value 的值是字符串或数字,那么 Select 会把它本身显示出来。

@PanJiaChen
Copy link
Contributor Author

@Leopoldthecoder 为什么不能做成像https://github.com/monterail/vue-multiselect/tree/2.0这样
其实不一定要同一对象才能初始化。
vue-multiselect 在传入value的情况下
image
根据你填写的label把对应的value显示出来就好了

@van048
Copy link

van048 commented Feb 21, 2024

2.13.2版本后,在el-select元素上加上属性value-key="key",即可

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants