vue中可編輯樹狀表格的實(shí)現(xiàn)代碼
vue中可編輯樹狀表格的代碼如下所示:
html代碼
<template>
<el-table
:data="datatree"
row-key="id"
:tree-props="{children: 'children'}"
>
<el-table-column label="姓名" border>
<template slot-scope="scope">
<el-input placeholder="請(qǐng)輸入內(nèi)容" v-show="scope.row.show" v-model="scope.row.label"></el-input>
<span v-show="!scope.row.show">{{scope.row.label}}</span>
</template>
</el-table-column>
<el-table-column label="操作">
<template slot-scope="scope">
<el-button @click="scope.row.show =true" >編輯</el-button>
<el-button @click="scope.row.show =false">保存</el-button>
</template>
</el-table-column>
</el-table>
</template>
js代碼
<script>
export default {
data(){
return {
datatree: [{
id: 1,
label: '水果',
show:false,
children: [{
id: 4,
label: '蘋果',
show:false,
children: [{
id: 9,
label: '蘋果皮',
show:false
}, {
id: 10,
label: '蘋果仔',
show:false
}]
}]
}, {
id: 2,
label: '蔬菜',
show:false,
children: [{
id: 5,
label: '青菜',
show:false
}, {
id: 6,
label: '土豆',
show:false
}]
}, {
id: 3,
label: '飲料',
show:false,
children: [{
id: 7,
label: '冰紅茶',
show:false
}, {
id: 8,
label: '酷兒',
show:false
}]
}],
defaultProps: {
children: 'children',
label: 'label',
show:'show'
}
}
}
}
效果圖

一個(gè)簡單的可編輯樹狀表格就出現(xiàn)了
嫌input框太大自己設(shè)置一下


到此這篇關(guān)于vue中可編輯樹狀表格的實(shí)現(xiàn)代碼的文章就介紹到這了,更多相關(guān)vue樹狀表格內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- vue+elementUI組件遞歸實(shí)現(xiàn)可折疊動(dòng)態(tài)渲染多級(jí)側(cè)邊欄導(dǎo)航
- vue + element ui實(shí)現(xiàn)播放器功能的實(shí)例代碼
- vue element后臺(tái)鑒權(quán)流程分析
- vue基于Element按鈕權(quán)限實(shí)現(xiàn)方案
- vue+element+oss實(shí)現(xiàn)前端分片上傳和斷點(diǎn)續(xù)傳
- 解決element DateTimePicker+vue彈出框只顯示小時(shí)
- Vue模仿ElementUI的form表單實(shí)例代碼
- 使用Vue實(shí)現(xiàn)一個(gè)樹組件的示例
- vue+iview使用樹形控件的具體使用
- Vue Element前端應(yīng)用開發(fā)之樹列表組件
相關(guān)文章
Vue引入sign-canvas實(shí)現(xiàn)簽名畫板效果
這篇文章主要介紹了Vue引入sign-canvas實(shí)現(xiàn)簽名畫板,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-03-03
vue使用el-table動(dòng)態(tài)合并列及行
這篇文章主要為大家詳細(xì)介紹了vue使用el-table動(dòng)態(tài)合并列及行,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-09-09
關(guān)于vue使用ant design vue,打包后a-date-picker控件無法選擇日期的問題
這篇文章主要介紹了關(guān)于vite .env.test環(huán)境使用ant design vue,打包后a-date-picker控件無法選擇日期的問題,本文針對(duì)這個(gè)問題提供了解決方法,需要的朋友可以參考下2023-04-04
Vue3響應(yīng)式對(duì)象數(shù)組不能實(shí)時(shí)DOM更新問題解決辦法
在寫大文件上傳時(shí),碰到關(guān)于 vue2 跟 vue3 對(duì)在循環(huán)中使用異步,并動(dòng)態(tài)把普通對(duì)象添加進(jìn)響應(yīng)式數(shù)據(jù),在異步前后修改該普通對(duì)象的某個(gè)屬性,導(dǎo)致 vue2 跟 vue3 的視圖更新不一致,引發(fā)一系列的思考,所以本文介紹了Vue3響應(yīng)式對(duì)象數(shù)組不能實(shí)時(shí)DOM更新問題解決辦法2024-07-07
vue+element UI實(shí)現(xiàn)樹形表格
這篇文章主要為大家詳細(xì)介紹了vue+element UI實(shí)現(xiàn)樹形表格,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-12-12
vue 項(xiàng)目中使用Loading組件的示例代碼
這篇文章主要介紹了vue 項(xiàng)目中使用Loading組件的示例代碼,使用 loding 過渡數(shù)據(jù)的加載時(shí)間2018-08-08
vue-resource請(qǐng)求實(shí)現(xiàn)http登錄攔截或者路由攔截的方法
這篇文章主要介紹了vue-resource請(qǐng)求實(shí)現(xiàn)http登錄攔截或者路由攔截的方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-07-07

