Use form mixin for add field change handler
This commit is contained in:
14
js/mixins/form.js
Normal file
14
js/mixins/form.js
Normal file
@@ -0,0 +1,14 @@
|
||||
export default {
|
||||
mounted: function () {
|
||||
this.$root.$on('field-change', this.handleFieldChange)
|
||||
},
|
||||
|
||||
methods: {
|
||||
handleFieldChange: function (event) {
|
||||
const { value, name } = event
|
||||
if (typeof this[name] !== undefined) {
|
||||
this[name] = value
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user