<template> <div> <el-date-picker v-model="nInput" :type="type" :placeholder="placeholder" :readonly="readonly" :disabled="disabled" :clearable="clearable" @input="salaryChange"></el-date-picker> </div> </template> <script> import { formatTimePicker } from '@/utils' export default { props: { value: { type: String, default: '' }, placeholder: { type: String }, clearable: { type: Boolean, default: false }, disabled: { type: Boolean, default: false }, readonly: { type: Boolean, default: false }, type: { type: String, default:'datetime' } }, data() { return { nInput: null } }, watch: { nInput(val, oldVal) { let dateVal = formatTimePicker(val,this.type) this.$emit('input', dateVal) }, value(val, oldVal) { this.nInput = val } }, created() { this.nInput = this.value }, methods: { salaryChange(e) { // console.log(e) } } } </script> <style lang="scss" scoped> </style>