vue3使用el-table實(shí)現(xiàn)新舊數(shù)據(jù)對(duì)比的代碼詳解
效果圖(不同數(shù)據(jù)用紅色字體標(biāo)出)

直接上代碼
<template>
<el-dialog v-model="dialogVisible" title="數(shù)據(jù)對(duì)比" width="40%" :before-close="handleClose">
<div class="c-table">
<el-table :data="tableDataRecords" border max-height="700px">
<el-table-column width="160px" prop="type" label=""></el-table-column>
<el-table-column prop="column1" :label="name.name1"> </el-table-column>
<el-table-column prop="column2" :label="name.name2">
<template #default="scope">
<div v-if="scope.row.column1 == scope.row.column2">{{ scope.row.column2 }}</div>
<div style="color: red" v-else>{{ scope.row.column2 }}</div>
</template>
</el-table-column>
<template #empty>
<img src="@/assets/images/common/no-data.png" alt="" width="179" />
</template>
</el-table>
</div>
</el-dialog>
</template>
<script setup>
import { ref } from 'vue'
const name = {
name1: '舊數(shù)據(jù)',
name2: '新數(shù)據(jù)'
}
const obj1 = ref()
const obj2 = ref()
const obj3 = ref()
const objChange = () => {
console.log(obj1.value, obj2.value, obj3.value)
for (const key in obj3.value) {
if (obj3.value.hasOwnProperty(key)) {
const record = {
type: obj3.value[key] ?? '--',
column1: obj2.value[key] ?? '--',
column2: obj1.value[key] ?? '--'
}
tableDataRecords.value.push(record)
}
}
}
const tableDataRecords = ref([])
// 打開彈出層
const dialogVisible = ref(false)
const compBtn = async (row, fileds) => {
tableDataRecords.value = []
dialogVisible.value = true
obj1.value = { a: '1', b: '2', c: '3' }
obj2.value = { a: '1', b: '2', c: '4' }
obj3.value = { a: '數(shù)據(jù)1', b: '數(shù)據(jù)2', c: '數(shù)據(jù)3' }
objChange()
}
defineExpose({
compBtn
})
</script>
<style lang="scss" scoped></style>以上就是vue3使用el-table實(shí)現(xiàn)新舊數(shù)據(jù)對(duì)比的代碼詳解的詳細(xì)內(nèi)容,更多關(guān)于vue3 el-table新舊數(shù)據(jù)對(duì)比的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
Vue實(shí)現(xiàn)關(guān)聯(lián)頁(yè)面多級(jí)跳轉(zhuǎn)(頁(yè)面下鉆)功能的完整實(shí)例
這篇文章主要給大家介紹了關(guān)于Vue實(shí)現(xiàn)關(guān)聯(lián)頁(yè)面多級(jí)跳轉(zhuǎn)(頁(yè)面下鉆)功能的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-03-03
Vue3項(xiàng)目打包并部署到Nginx實(shí)踐
本文介紹了如何安裝Nginx并部署Vue項(xiàng)目,首先從官網(wǎng)下載Nginx并啟動(dòng)服務(wù),然后使用Vite構(gòu)建Vue項(xiàng)目,將構(gòu)建好的dist文件夾部署到Nginx目錄下,并修改nginx.conf文件以防止刷新頁(yè)面時(shí)出現(xiàn)404錯(cuò)誤,最后,總結(jié)了刷新頁(yè)面空白問(wèn)題的解決方法2026-01-01
vue項(xiàng)目ElementUI組件中el-upload組件與圖片裁剪功能組件結(jié)合使用詳解
這篇文章主要介紹了vue項(xiàng)目ElementUI組件中el-upload組件與圖片裁剪功能組件結(jié)合使用,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-03-03
Vue-CLI3.x 自動(dòng)部署項(xiàng)目至服務(wù)器的方法步驟
本教程講解的是 Vue-CLI 3.x 腳手架搭建的vue項(xiàng)目, 利用scp2自動(dòng)化部署到靜態(tài)文件服務(wù)器 Nginx,感興趣的可以了解一下2021-11-11
vue3按鈕點(diǎn)擊頻率控制的實(shí)現(xiàn)示例
在前端開發(fā)中,當(dāng)用戶頻繁連續(xù)點(diǎn)擊按鈕,可能會(huì)導(dǎo)致頻繁的請(qǐng)求或者觸發(fā)過(guò)多的操作,本文主要介紹了vue3按鈕點(diǎn)擊頻率控制的實(shí)現(xiàn)示例,感興趣的可以了解一下2024-01-01

