Skip to content

Commit

Permalink
表单数据回填示例
Browse files Browse the repository at this point in the history
  • Loading branch information
huangjie committed May 29, 2020
1 parent d7332d4 commit dcafd0f
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/components/parser/example/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,29 @@ export default {
computed: {},
watch: {},
created() {},
mounted() {},
mounted() {
// 表单数据回填,模拟异步请求场景
setTimeout(() => {
// 请求回来的表单数据
const data = {
mobile: '18836662555'
}
// 回填数据
this.fillFormData(this.formConf, data)
// 更新表单
this.key2 = +new Date()
}, 2000)
},
methods: {
fillFormData(form, data) {
form.fields.map(item => {
const val = data[item.__vModel__]
if (val) {
item.__config__.defaultValue = val
}
return item
})
},
change() {
this.key2 = +new Date()
const t = this.formConf
Expand Down

0 comments on commit dcafd0f

Please sign in to comment.