您好,登錄后才能下訂單哦!
這篇文章給大家分享的是有關(guān)vue樹形控件tree怎么用的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過來看看吧。
具體內(nèi)容如下
<template> <div class="hello tree-container"> <el-tree :data="data" show-checkbox node-key="id" class="tree" :allow-drop="allowDrop" :props="defaultProps" :default-expanded-keys="[2, 3]" :default-checked-keys="[5]"> </el-tree> </div> </template>
<script> export default { name: 'HelloWorld', data () { return { msg: 'Welcome to Your Vue.js App|', data: [{ id: 1, label: '一級(jí) 2', children: [{ id: 3, label: '二級(jí) 2-1', children: [{ id: 4, label: '三級(jí) 3-1-1' }, { id: 5, label: '三級(jí) 3-1-2', disabled: true }] }, { id: 2, label: '二級(jí) 2-2', disabled: true, children: [{ id: 6, label: '三級(jí) 3-2-1' }, { id: 7, label: '三級(jí) 3-2-2', disabled: true, children: [{ id: 8, label: '二級(jí) 8-1', children: [{ id: 9, label: '三級(jí) 3-1-1' }, { id: 10, label: '三級(jí) 3-1-2', disabled: true }] }] }] }] }], defaultProps: { // 用于修改節(jié)點(diǎn)指定標(biāo)簽的屬性值 children: 'children', label: 'label' } } }, methods: { allowDrop(draggingNode, dropNode, type) { if (draggingNode.parrent.id=== dropNode.parrent.id) { return type !== 'next'; } else { return true; } } } } </script> <!-- Add "scoped" attribute to limit CSS to this component only --> <style scoped> /* 樹形結(jié)構(gòu)節(jié)點(diǎn)添加連線 */ .tree /deep/ .el-tree-node { position: relative; padding-left: 16px; } .tree /deep/ .el-tree-node__children { padding-left: 12px; } .tree /deep/ .el-tree-node :last-child:before { height: 50px; } .tree /deep/ > .el-tree-node:before { border: none !important; } .tree /deep/ .el-tree > .el-tree-node:before { border-left: none; } .tree-container /deep/ .el-tree > .el-tree-node:after { border-top: none; } .tree /deep/ .el-tree-node:before { content: ""; left: -4px; position: absolute; right: auto; border-width: 1px; } .tree /deep/ .el-tree-node:after { content: ""; left: -4px; position: absolute; right: auto; border-width: 1px; } .tree /deep/ .el-tree-node__expand-icon.is-leaf { display: none; } .tree /deep/ .el-tree-node:before { border-left: 1px solid #b8b9bb; bottom: 0px; height: 100%; top: -26px; width: 1px; } .tree /deep/ .el-tree-node:after { border-top: 1px solid #b8b9bb; height: 20px; top: 24px; width: 20px; } .tree /deep/ .el-tree-node__expand-icon{ display: none; } .tree /deep/ .el-tree-node__content{ padding-left: 0 !important; } .tree /deep/ .el-tree-node__content { height: 18px;padding-top: 16px; } </style>
感謝各位的閱讀!關(guān)于“vue樹形控件tree怎么用”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。