vue3使用el-table實(shí)現(xiàn)新舊數(shù)據(jù)對(duì)比的代碼詳解
更新時(shí)間:2023年12月03日 10:17:42 作者:許個(gè)愿~
這篇文章主要為大家詳細(xì)介紹了在vue3中使用el-table實(shí)現(xiàn)新舊數(shù)據(jù)對(duì)比,文中的示例代碼講解詳細(xì),具有一定的參考價(jià)值,需要的小伙伴可以參考一下
效果圖(不同數(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使用mounted和created時(shí),this無法指向data中的數(shù)據(jù)問題
這篇文章主要介紹了Vue使用mounted和created時(shí),this無法指向data中的數(shù)據(jù)問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-07-07Vue實(shí)施重新發(fā)布和軟件熱更新的經(jīng)驗(yàn)分享
在Web應(yīng)用的開發(fā)周期中,版本管理和軟件熱更新是一個(gè)不可或缺的話題,隨著Vue.js框架的流行,越來越多的應(yīng)用程序選擇使用Vue來構(gòu)建前端,本文將探討在Vue應(yīng)用中實(shí)施重新發(fā)布和熱更新的最佳實(shí)踐,需要的朋友可以參考下2024-09-09vue.config.js中devServer.proxy配置說明及配置正確不生效問題解決
Vue項(xiàng)目devServer.proxy代理配置詳解的是一個(gè)非常常見的需求,下面這篇文章主要給大家介紹了關(guān)于vue.config.js中devServer.proxy配置說明及配置正確不生效問題解決的相關(guān)資料,需要的朋友可以參考下2023-02-02Vue項(xiàng)目前端部署詳細(xì)步驟(nginx方式)
Nginx(engine x)是一個(gè)高性能的HTTP和反向代理web服務(wù)器,是部署前端項(xiàng)目的首選,這篇文章主要給大家介紹了關(guān)于Vue項(xiàng)目前端部署(nginx方式)的相關(guān)資料,需要的朋友可以參考下2023-09-09vue做移動(dòng)端適配最佳解決方案(親測(cè)有效)
這篇文章主要介紹了vue做移動(dòng)端適配最佳解決方案(親測(cè)有效),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-09-09