vue-form-generator-element-gt4w
Version:
Element (https://element.eleme.io) fields for vue-form-generator
20 lines (18 loc) • 461 B
JavaScript
const defaultValueSetter = {
created() {
if (!this.model) {
return;
}
if (typeof this.value === "undefined") {
if (
this.schema.hasOwnProperty("model") &&
this.model.hasOwnProperty(this.schema.model)
) {
this.value = this.model[this.schema.model];
} else if (this.schema.hasOwnProperty("default")) {
this.value = this.schema.default;
}
}
}
};
export default defaultValueSetter;