Element-ui框架Tree樹形控件切換高亮顯示選中效果


原文鏈接: 原文
代碼:
<div class="warpper"> </div>
<script type="text/javascript">// <![CDATA[
    export default {
        data() {
            return {
                ParmentData: null,
                TreeData: [
                    {
                        id: 1,
                        label: '一級 1',
                        children: [
                            {
                                id: 4,
                                label: '二級 1-1',
                                children: [
                                    { id: 9, label: '三級 1-1-1' },
                                    { id: 10, label: '三級 1-1-2' }
                                ]
                            }
                        ]
                    }, {
                        id: 2,
                        label: '一級 2',
                        children: [
                            {
                                id: 5,
                                label: '二級 2-1'
                            }, {
                                id: 6,
                                label: '二級 2-2'
                            }
                        ]
                    }, {
                        id: 3,
                        label: '一級 3',
                        children: [
                            {
                                id: 7,
                                label: '二級 3-1'
                            }, {
                                id: 8,
                                label: '二級 3-2'
                            }
                        ],
                        show: true
                    }],
                defaultProps: {
                    children: 'children',
                    label: 'label'
                },
                treeKey:'',
            }
        },
        created() {
            this.$nextTick(function(){
                this.$data.TreeData.forEach(row => {
                    if(row.show){
                        this.$refs.tree.setCurrentKey(row.id);
                        this.$refs.tree.store.nodesMap[row.id].expanded = true;
                    }
                })
            })
        },
        methods: {
            handleNodeClick: function (data,checked) {
                // 點擊事件
            },
            handleCheckChange(data, checked, indeterminate) {
                console.log(data, checked, indeterminate);
            },
        }
    }
// ]]></script>
<style><!--
 .warpper .el-tree--highlight-current /deep/ .el-tree-node.is-checked > .el-tree-node__content {
    background-color: rgb(255, 255, 255);
    color:rgb(64, 158, 255);
  }
 .warpper .el-tree--highlight-current /deep/ .el-tree-node.is-current > .el-tree-node__content {
    background-color: rgb(255, 255, 255);
    color:rgb(64, 158, 255);
  }
--></style>

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM