element-plus+Vue3實(shí)現(xiàn)表格數(shù)據(jù)動(dòng)態(tài)渲染
前言:
最近跟小伙伴一起從0到1一起搭建一個(gè)面試學(xué)習(xí)系統(tǒng),學(xué)習(xí)使用element-plus框架動(dòng)態(tài)渲染從后端獲取的數(shù)據(jù),在這里跟諸位大佬一起分享:
話不多說(shuō),上代碼:
<div class="home_company"> <el-table :data="getHomeShowAllCompany.companyArr" //使用data屬性動(dòng)態(tài)綁定需要展示的數(shù)組 height="auto" //height屬性自適應(yīng) border style="width: 100%" > //labal表示表頭展示的名稱 prop屬性與數(shù)組中本列需要展示的數(shù)據(jù)名對(duì)應(yīng) <el-table-column label="公司名稱" prop="company_name"> </el-table-column> <el-table-column label="公司所在地" prop="company_location"> </el-table-column> <el-table-column label="公司官網(wǎng)" prop="website"> //如果你需要對(duì)數(shù)據(jù)進(jìn)行其他的處理,你需要使用插槽scope.row.本行的任意屬性名,即可以獲得對(duì)應(yīng)數(shù)據(jù) <template #default="scope"> <a :href="scope.row.website" rel="external nofollow" style="text-decoration: none; color: rgb(107, 164, 228)" >{{ scope.row.website }}</a > </template> </el-table-column> <el-table-column label="面試記錄" width="90" align="center"> <template #default="scope"> <el-button type="primary" plain //插槽里的數(shù)據(jù)也可以作為參數(shù)進(jìn)行傳遞 @click="searchInterviewRecode(scope.row.ID)" >搜索</el-button > </template> </el-table-column> </el-table> </div> <script setup> //引用倉(cāng)庫(kù)獲取公司數(shù)據(jù) import { homeShowAllCompanyStore } from "@/store/home"; import { showAllRecords } from "~~/api/index"; //將請(qǐng)求到的全部公司的數(shù)組存在getHomeShowAllCompany中 let getHomeShowAllCompany = homeShowAllCompanyStore(); //傳遞的參數(shù) let company_name = ref(""); let company_location = ref(""); let scale = ref(0); let page = ref(1); let pageSize = ref(10); function searchInterviewRecode(ID) { showAllRecords(ID); } </script>
后端返回?cái)?shù)據(jù)展示:
實(shí)現(xiàn)效果展示:
到此這篇關(guān)于element-plus+Vue3實(shí)現(xiàn)表格數(shù)據(jù)動(dòng)態(tài)渲染的文章就介紹到這了,更多相關(guān)element Vue3表格動(dòng)態(tài)渲染內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Vue3?<script?setup?lang=“ts“>?的基本使用
<script setup>?是在單文件組件 (SFC) 中使用?composition api?的編譯時(shí)語(yǔ)法糖,本文主要講解<script setup>?與?TypeScript?的基本使用,感興趣的朋友跟隨小編一起看看吧2022-12-12Vue+ElementUI前端添加展開(kāi)收起搜索框按鈕完整示例
最近一直在用element ui做后臺(tái)項(xiàng)目,下面這篇文章主要給大家介紹了關(guān)于Vue+ElementUI前端添加展開(kāi)收起搜索框按鈕的相關(guān)資料,文中通過(guò)代碼介紹的非常詳細(xì),需要的朋友可以參考下2024-05-05vue-cli腳手架打包靜態(tài)資源請(qǐng)求出錯(cuò)的原因與解決
這篇文章主要給大家介紹了關(guān)于vue-cli腳手架打包靜態(tài)資源請(qǐng)求出錯(cuò)的原因與解決方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用vue-cli具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-06-06詳解.vue文件中style標(biāo)簽的幾個(gè)標(biāo)識(shí)符
這篇文章主要介紹了詳解.vue文件中style標(biāo)簽的幾個(gè)標(biāo)識(shí)符,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-07-07vue開(kāi)發(fā)調(diào)試神器vue-devtools使用詳解
這篇文章主要為大家詳細(xì)介紹了vue開(kāi)發(fā)調(diào)試神器vue-devtools的使用方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-07-07vue的style綁定background-image的方式和其他變量數(shù)據(jù)的區(qū)別詳解
今天小編就為大家分享一篇vue的style綁定background-image的方式和其他變量數(shù)據(jù)的區(qū)別詳解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-09-09