lljj-x / vue-json-schema-form

基于Vue/Vue3,Json Schema 和 ElementUi/antd/iview3/naiveUi 等生成 HTML Form 表单,用于活动编辑器、h5编辑器、cms等数据配置;支持可视化生成表单Schema 。 Generate a form using Vue/Vue3, Json Schema and ElementUi/antdv/iview3/naiveUi
https://form.lljj.me/
Apache License 2.0
2.01k stars 418 forks source link

多选数组不支持设置默认值嘛 #271

Closed yangliguo7 closed 1 year ago

yangliguo7 commented 1 year ago
{
  "schema": {
    "type": "object",
    "required": [],
    "properties": {
      "array_1677151659800x0": {
        "type": "array",
        "uniqueItems": true,
        "items": {
          "type": "string",
          "enum": [
            "1",
            "2",
            "3"
          ],
          "enumNames": [
            "一",
            "二",
            "三"
          ]
        },
        "title": "多选(Select)",
        "ui:widget": "SelectWidget"
      }
    },
    "ui:order": [
      "array_1677151659800x0"
    ]
  },
  "uiSchema": {},
  "formFooter": {
    "show": false
  },
  "formProps": {
    "labelWidth": "100px",
    "labelSuffix": ":"
  }
}

设置default 没用

lljj-x commented 1 year ago

image 这里面加上default 是可以的

yangliguo7 commented 1 year ago

设置并没有作用

{
  "schema": {
    "type": "object",
    "required": [],
    "properties": {
      "array_1677151659800x0": {
"default": ["1","2"],
        "type": "array",
        "uniqueItems": true,
        "items": {
          "type": "string",
          "enum": [
            "1",
            "2",
            "3"
          ],
          "enumNames": [
            "一",
            "二",
            "三"
          ]
        },
        "title": "多选(Select)",
        "ui:widget": "SelectWidget"
      }
    },
    "ui:order": [
      "array_1677151659800x0"
    ]
  },
  "uiSchema": {},
  "formFooter": {
    "show": false
  },
  "formProps": {
    "labelWidth": "100px",
    "labelSuffix": ":"
  }
}

单独纯文本标签是可以生效的

@lljj-x

lljj-x commented 1 year ago

用的你的schema也没问题 playground

yangliguo7 commented 1 year ago

是的,然而在 https://form.lljj.me/schema-generator.html#/index 这里去导入schema 却不表现出默认值

感谢回复