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

cascader的change的回调只能给一个value的值吗?能不能给一个方法让可以取到选中选项的完整对象 #2343

Closed
cao1987 opened this issue Apr 19, 2023 · 3 comments
Assignees
Labels
🤔 Question Further information is requested

Comments

@cao1987
Copy link

cao1987 commented Apr 19, 2023

有时候需要拿到已选中选项的一些其他附带的参数,现在根本取不到,只能再自己去用原数据筛选出来,这样太麻烦了吧

@flsion
Copy link
Member

flsion commented Apr 21, 2023

@cao1987 这种场景可以使用对象格式的 value,使用 value-key 绑定上一个 key,这时会返回整个 value 对象

@flsion flsion closed this as completed Apr 21, 2023
@flsion flsion added the 🤔 Question Further information is requested label Apr 21, 2023
@flsion flsion self-assigned this Apr 21, 2023
@chenzhe-pro
Copy link

value
有示例代码吗?官网没看到示例代码

@ericzhao007
Copy link

回答太抽象了,试了一下,数据结构改成

[
    {
        "label": "111",
        "value": {
            "id": 1,
            "name": "111-1"
        }
        
    }
]

<a-cascader
v-model="goodsItem.goods_id"
allow-search
:options="options"
value-key="id"
placeholder="请选择商品"
@change="handleChangeGoods"
/>

注意value-key需要设置为id或主键字段,这样handleChangeGoods 收到的是value对象

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤔 Question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants