diffData: '', // 差异
this.compiles = res.data.data[0] 当前数据
this.rawData = {...res.data.data[0]} // 原始数据
// 比较差异的方法
diffFormData () {
for (let k in this.rawData) {
if (this.rawData[k] !== this.compiles[k]) {
if (!this.diffData) {
this.diffData = {}
}
this.diffData[k] = this.compiles[k]
}
}
},
// 表单提及
submitClicks() {
const that = this
//先比对差异赋值给diffData,如果diffData为空则不用提交,不为空则进行提交
this.diffFormData()
if (!this.diffData) {
this.$message.error('未修改任何数据,无需提交')
}
}
vue form表单对比差异
最新推荐文章于 2024-07-08 16:06:13 发布