1、引入方法
import { formatDateNew } from '@/utils'
2、在方法中使用,注意要先将字符串进行new Date(),否则报错date.getFullYear is not a function
methods: { openDialog(data) { console.log(data) this.dialogFormVisible = true this.edit = Object.assign({}, data) this.edit.productionDate = formatDateNew(new Date(this.edit.productionDate), 'yyyy-MM-dd') this.edit.expireDate = formatDateNew(new Date(this.edit.expireDate), 'yyyy-MM-dd') console.log(this.edit) }, }