Vue組件庫(kù)ElementUI實(shí)現(xiàn)表格加載樹(shù)形數(shù)據(jù)教程
ElementUI實(shí)現(xiàn)表格樹(shù)形列表加載教程,供大家參考,具體內(nèi)容如下
Element UI 是一套采用 Vue 2.0 作為基礎(chǔ)框架實(shí)現(xiàn)的組件庫(kù),一套為開(kāi)發(fā)者、設(shè)計(jì)師和產(chǎn)品經(jīng)理準(zhǔn)備的基于 Vue 2.0 的組件庫(kù),提供了配套設(shè)計(jì)資源,幫助網(wǎng)站快速成型
關(guān)鍵代碼,在el-table添加屬性, :tree-props="{children: 'children'}" ,注意row必須命名為children,官網(wǎng)也進(jìn)行了說(shuō)明:
支持樹(shù)類型的數(shù)據(jù)的顯示。當(dāng) row 中包含 children 字段時(shí),被視為樹(shù)形數(shù)據(jù)。渲染樹(shù)形數(shù)據(jù)時(shí),必須要指定 row-key。支持子節(jié)點(diǎn)數(shù)據(jù)異步加載。設(shè)置 Table 的 lazy 屬性為 true 與加載函數(shù) load 。通過(guò)指定 row 中的 hasChildren 字段來(lái)指定哪些行是包含子節(jié)點(diǎn)。children 與 hasChildren 都可以通過(guò) tree-props 配置。
<el-table ref="Table" :data="apprItemData" :header-cell-style="headClass" @select="handleSelection" row-key="approveItem" height="420" border default-expand-all :tree-props="{children: 'children'}"> <el-table-column type="selection" width="55"> </el-table-column> <el-table-column prop="itemCode" label="事項(xiàng)編碼"> </el-table-column> <el-table-column prop="approveName" label="事項(xiàng)名稱"> </el-table-column> <el-table-column prop="apprStatusStr" label="配置的環(huán)節(jié)" color="blue"> </el-table-column> </el-table>
后臺(tái)json數(shù)據(jù):
{ "id":3, "itemCode":"123", "approveName":"測(cè)試事項(xiàng)", "apprStatusStr":"環(huán)節(jié)名稱", "children":[ { "id":31, "itemCode":"111", "approveName":"測(cè)試事項(xiàng)", "apprStatusStr":"環(huán)節(jié)名稱" } ] }
<script type="text/babel"> var vm = new Vue({ el: '#app', data:{ apprItemData : [], currentPage: 1, //當(dāng)前頁(yè) totalRow: 0, //總頁(yè)數(shù) pageSize: 10 //當(dāng)前顯示條數(shù) }, computed: {}, watch: {}, created() {}, mounted() { this.loadItemData(); }, methods: { // 加載事項(xiàng)信息 loadItemData () { var pageSize = this.pageSize; var currentPage = this.currentPage; console.log("pageSize:"+pageSize+",currentPage:"+currentPage); //debugger; var geturl = '${root}/config/loadItemData.do?rows='+pageSize + '&page=' + currentPage; $.ajax({ type: 'get', url:geturl, contentType: "application/json; charset=utf-8", success: function(data) { //debugger; console.log("totalRow:"+data.total); vm.apprItemData = data.rows; }, error: function(e) { console.log("更新數(shù)據(jù)出現(xiàn)錯(cuò)誤:",e); } }) } } }); </script>
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Vue3+vite實(shí)現(xiàn)使用svg可改變顏色的全過(guò)程
Vue3 + Vite 使用 SVG 的方法主要是為了引入和利用圖標(biāo)庫(kù)、自定義組件以及通過(guò)插件簡(jiǎn)化項(xiàng)目構(gòu)建過(guò)程,這篇文章給大家介紹了Vue3+vite實(shí)現(xiàn)使用svg可改變顏色的全過(guò)程,需要的朋友可以參考下2024-07-07Vue實(shí)現(xiàn)的父組件向子組件傳值功能示例
這篇文章主要介紹了Vue實(shí)現(xiàn)的父組件向子組件傳值功能,結(jié)合完整實(shí)例形式簡(jiǎn)單分析了vue.js組件傳值的相關(guān)操作技巧,需要的朋友可以參考下2019-01-01解決Vue中的生命周期beforeDestory不觸發(fā)的問(wèn)題
這篇文章主要介紹了解決Vue中的生命周期beforeDestory不觸發(fā)的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-07-07解決報(bào)錯(cuò)ValidationError: Progress Plugin Invalid&
這篇文章主要介紹了解決報(bào)錯(cuò)ValidationError: Progress Plugin Invalid Options問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-11-11vue3中調(diào)用api接口實(shí)現(xiàn)數(shù)據(jù)的渲染以及詳情方式
這篇文章主要介紹了vue3中調(diào)用api接口實(shí)現(xiàn)數(shù)據(jù)的渲染以及詳情方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-08-08關(guān)于vue-resource報(bào)錯(cuò)450的解決方案
本篇文章主要介紹關(guān)于vue-resource報(bào)錯(cuò)450的解決方案,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-07-07VUE+Express+MongoDB前后端分離實(shí)現(xiàn)一個(gè)便簽墻
這篇文章主要介紹了VUE+Express+MongoDB前后端分離實(shí)現(xiàn)一個(gè)便簽墻,需要的朋友可以參考下2021-04-04vuex頁(yè)面刷新導(dǎo)致數(shù)據(jù)丟失的解決方案
這篇文章主要介紹了vuex頁(yè)面刷新導(dǎo)致數(shù)據(jù)丟失的解決方案,幫助大家更好的使用vue框架,感興趣的朋友可以了解下2020-12-12