cube-ui / question-answer

Q&A for cube-ui
16 stars 7 forks source link

form表单的配置能否动态化? #62

Closed LiyinZhang closed 5 years ago

LiyinZhang commented 5 years ago

form表单代码如下:

model定义如下: model: { educationList: [ { educationStartDate: "", educationEndDate: "", schoolName: "", major: "", degree: "", eduType: "" } ] } datas定义如下: [ { groupTitle: "教育信息", multiterm: true, // 是否多条数据 groupList: [ { groupType: "list", fields: [ { type: "dataselect", modelKey: "educationInfoDtos[0].educationStartDate", label: "开始时间", rules: { required: true } }, { type: "input", modelKey: "educationInfoDtos[0].schoolName", label: "学校名称", props: { placeholder: "请输入" }, rules: { required: true }, trigger: "blur" }, { type: "select", modelKey: "educationInfoDtos[0].eduType", label: "学历", props: { options: ['本科', '大专'] } // rules: { // required: true // } } ] } ]

界面效果如下: image

当点击界面的添加按钮,会增加多一条教育信息,那么想问一下datas里面的modelKey应该怎么跟model建立关联,能做到这种需求吗?

dolymood commented 5 years ago

目测 使用 computed 可解决

LiyinZhang commented 5 years ago

你好,那我想问一下modelKey应该怎么写,可以举例一下?我现在是不知道model应该怎么跟modelkey关联起来。

------------------ 原始邮件 ------------------ 发件人: "doly mood"notifications@github.com; 发送时间: 2019年5月17日(星期五) 下午5:04 收件人: "cube-ui/question-answer"question-answer@noreply.github.com; 抄送: "张力音"963696044@qq.com;"Author"author@noreply.github.com; 主题: Re: [cube-ui/question-answer] form表单的配置能否动态化? (#62)

目测 使用 computed 可解决

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

dolymood commented 5 years ago

model不支持复杂表达式,这个很容易有替代方案

LiyinZhang commented 5 years ago

就是想不出替代方案 项目卡在这里进行不下去了 方便说一下替代方案吗?

------------------ 原始邮件 ------------------ 发件人: "doly mood"notifications@github.com; 发送时间: 2019年5月17日(星期五) 下午5:29 收件人: "cube-ui/question-answer"question-answer@noreply.github.com; 抄送: "张力音"963696044@qq.com;"Author"author@noreply.github.com; 主题: Re: [cube-ui/question-answer] form表单的配置能否动态化? (#62)

model不支持复杂表达式,这个很容易有替代方案

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

dolymood commented 5 years ago

model 直接是对象,剩下的自己映射即可。