一、效果展示
- 说明:点击左边或右边某个树节点,对应树节点也会跟着展开、收起。
- 举例1:当前状态下,点击左侧树节点【2】,该节点收起,右侧树节点【B】也会收起。
- 举例2:当前状态下,点击右侧树节点【A-a】,该节点展开,左侧树节点【1-0】也会展开。

二、代码实现
<template>
<div class="box">
<a-row class="box-height">
<a-col :span="12" class="box-border">
<a-tree :expanded-keys="leftExpandedKeys" :tree-data="leftTreeData" @expand="onLeftExpand" />
</a-col>
<a-col :span="12">
<a-tree
:expanded-keys="rightExpandedKeys"
:tree-data="rightTreeData"
@expand="onRightExpand"
/>
</a-col>
</a-row>
</div>
</template>
<script>
const leftTreeData = [
{
title: '1',
key: '1',
children: [
{
title: '1-0',
key: '1-0',
children: [
{
title: '1-0-0', key: '1-0-0' },
{
title: '1-0-1', key: '1-0-1' },
{
title: '1-0-2', key: '1-0-2' },
],
},
{
title: '1-1',
key: '1-1',
children: [
{