Skip to content

Commit a7a8b99

Browse files
committed
fix: 自定义区域无法绑定数据
1 parent 483798a commit a7a8b99

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

doc/blank.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
## 自定义扩展字段
22

3-
**开发者使用该字段可以通过代码引用的方式添加自己想要的组件**
3+
该扩展相当于是引入一个作用域插槽,可以参考[作用域插槽](https://cn.vuejs.org/v2/guide/components-slots.html#%E4%BD%9C%E7%94%A8%E5%9F%9F%E6%8F%92%E6%A7%BD)
44

5-
> 使用此功能需要element-ui版本在v2.5.0之前,否则无法绑定数据,已经向element-ui提交bug
5+
下面来看看步骤:
66

77
1. 首先在设计器中配置需要绑定的数据key和数据类型,这里需要设置下你绑定的到表单中的数据类型,防止类型报错
88

9-
![](https://user-gold-cdn.xitu.io/2018/10/27/166b55ab4883ecbe?w=1127&h=341&f=png&s=27636)
9+
![](https://user-gold-cdn.xitu.io/2018/10/27/166b55ab4883ecbe?w=1127&h=341&f=png&s=27636)
1010

11-
2. 在 fm-generate-form 中引入自定义组件,如:
11+
2. 在 fm-generate-form 中引入自定义内容,如:
1212

13-
```html
13+
```html
1414
<generate-form >
15-
<template slot="blank" slot-scope="scope">
16-
宽度:<el-input v-model="scope.model.blank.width" style="width: 100px"></el-input>
17-
高度:<el-input v-model="scope.model.blank.height" style="width: 100px"></el-input>
18-
</template>
19-
</generate-form>
20-
```
21-
22-
3. 预览效果如下:
15+
<template slot="blank" slot-scope="scope">
16+
宽度:<el-input v-model="scope.model.blank.width" style="width: 100px"></el-input>
17+
高度:<el-input v-model="scope.model.blank.height" style="width: 100px"></el-input>
18+
</template>
19+
</generate-form>
20+
```
21+
22+
3. 至此自定义内容区域就绑定好了,预览效果如下:
2323

2424
![](https://user-gold-cdn.xitu.io/2018/10/27/166b5a15b837f3fe?w=867&h=320&f=png&s=18568)

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"ace-builds": "^1.4.3",
2828
"axios": "^0.18.0",
2929
"clipboard": "^2.0.1",
30-
"element-ui": "^2.4.11",
30+
"element-ui": "^2.9.1",
3131
"multiparty": "^4.2.1",
3232
"normalize.css": "^8.0.0",
3333
"qiniu": "^7.2.1",

src/components/GenerateForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export default {
7474
this.models[genList[i].model] = this.value[genList[i].model]
7575
} else {
7676
if (genList[i].type === 'blank') {
77-
this.models[genList[i].model] = genList[i].options.defaultType === 'String' ? '' : (genList[i].options.defaultType === 'Object' ? {} : [])
77+
this.$set(this.models, genList[i].model, genList[i].options.defaultType === 'String' ? '' : (genList[i].options.defaultType === 'Object' ? {} : []))
7878
} else {
7979
this.models[genList[i].model] = genList[i].options.defaultValue
8080
}

0 commit comments

Comments
 (0)