Skip to content

Commit

Permalink
fix(dynamic-field): using v-model, fix component api
Browse files Browse the repository at this point in the history
  • Loading branch information
leomp12 committed Dec 6, 2019
1 parent dc88af2 commit 6b78718
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
3 changes: 1 addition & 2 deletions src/components/html/EcDynamicField.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
v-bind="{name: field, schema: schema}"
v-if="dynamicField"
:key="field"
:value="value"
@input="$emit('input', $event)"
v-model="localValue"
:is="dynamicField"
/>
</div>
23 changes: 14 additions & 9 deletions src/components/js/EcDynamicField.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@ import { discover } from '../../utils/Discoverer.js'

export default {
name: 'EcDynamicField',

props: {
field: {
type: String
},
schema: {
type: Object
},
value: {
type: [String, Number, Boolean, Object]
}
field: String,
schema: Object,
value: [String, Number, Boolean, Object]
},

computed: {
localValue: {
get () {
return this.value
},
set (value) {
this.$emit('input', value)
}
},

dynamicFields () {
return discover(this.field, this.schema)
}
Expand Down

0 comments on commit 6b78718

Please # to comment.