1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| import { DatePicker } from "element-ui"; export default { inheritAttrs: false, data() { return { inputValue: "" }; }, props: { format: { type: String, default: "" } }, model: { prop: "value", event: "change" }, components: { ElDatePicker: DatePicker }, methods: { setValue() { this.$nextTick() .then(result => { const value = this.$el.children[0].children[0].children[0].value; this.$emit("change", value); this.dispatch("ElFormItem", "el.form.change", [value]); }) .catch(err => {}); }, dispatch(componentName, eventName, params) { let parent = this.$parent || this.$root; let name = parent.$options.componentName; while (parent && (!name || name !== componentName)) { parent = parent.$parent; if (parent) { name = parent.$options.componentName; } } if (parent) { parent.$emit.apply(parent, [eventName].concat(params)); } } }, watch: { value() { if (this.value != this.inputValue) { this.inputValue == this.value; } } } };
|