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 下拉框设置多选,提示“应当是预设定的枚举值之一” #373

Open
w582745483 opened this issue Dec 9, 2024 · 3 comments

Comments

@w582745483
Copy link

反馈问题请先查看文档和务必提供详细的复现代码,遵循如下格式,描述不清楚的问题将会直接关闭。

vue和ui框架

vue3、ui框架elementPlus、vjsf "@lljj/vue3-form-element": "^1.19.0",

问题描述

让el-select 设置为多选时,选中下拉框,或者初始化时给下拉框的v-model设置初始值为数组(为enum中的值),会报错“应当是预设定的枚举值之一”

如何复现

可以详细介绍你的复现场景或者相关代码。

必要时提供复现demo,如codepen,github 复现仓库,playground分享链接等
https://form.lljj.me/v3/#/demo?ui=VueElementForm&type=Test&schema={%22title%22:%22%E6%B5%8B%E8%AF%95%E6%B3%A8%E5%86%8C%E8%A1%A8%E5%8D%95%22,%22description%22:%22A+simple+form+example.%22,%22type%22:%22object%22,%22properties%22:{%22numberEnum%22:{%22title%22:%22Number+enum+(select)%22,%22enum%22:[1,2,3],%22enumNames%22:[%22Select+-+1%22,%22Select+-+2%22,%22Select+-+3%22],%22ui:options%22:{%22multiple%22:true}}}}&formData={%22numberEnum%22:[3,2]}&uiSchema={}&errorSchema={}&formFooter={%22show%22:true}&formProps={%22inline%22:false,%22labelPosition%22:%22top%22,%22inlineFooter%22:false,%22layoutColumn%22:1,%22labelWidth%22:%22100px%22}

期望的结果

不要报错“应当是预设定的枚举值之一”

@lljj-x
Copy link
Owner

lljj-x commented Dec 9, 2024

这里 schema 描述的数据类型是 number,但通过ui配置成了一个 array类型。所以验证不通过

array 应该使用下面这个schema 结构

"multipleChoicesList": {
    "type": "array",
    "title": "A multiple choices list",
    "items": {
        "type": "string",
        "enum": [
            "foo",
            "bar",
            "fuzz",
            "qux"
        ]
    },
    "uniqueItems": true
}

@w582745483
Copy link
Author

我需要的select 多选,并不是checkbox单选框

@lljj-x
Copy link
Owner

lljj-x commented Dec 10, 2024

"ui:widget": "SelectWidget"

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

2 participants