vue-ele-form-yd
Version:
基于 element-ui 的数据驱动表单组件
45 lines (40 loc) • 1.21 kB
JavaScript
import dayjs from 'dayjs'
export default {
data () {
return {
type: ['Date', 'String', 'Number']
}
},
methods: {
// displayModel===>dataModel
// 存储数据格式化方法
custormValueFormatter(value) {
let newVal = value
if (value && !(this.attrs.valueFormat || this.attrs['value-format'])) {
newVal = dayjs(value).unix()
}
return newVal
}
// 覆盖 formMixin 中的 handleChange, 将值转为 unix 时间戳
// handleChange (value) {
// let newVal = value
// if (value && !(this.attrs.valueFormat || this.attrs['value-format'])) {
// newVal = dayjs(value).unix()
// }
// this.$emit('input', newVal)
// },
// // 获取值: 数字(秒 -> 毫秒) / 字符串
// getValue (value) {
// if (value && !(this.attrs.valueFormat || this.attrs['value-format'])) {
// value = typeof value === 'number' ? value * 1000 : value
// return dayjs(value).format()
// } else {
// return value
// }
// },
// // 自定义值处理
// customInit (value) {
// return this.getValue(value)
// }
}
}