72 lines
1.8 KiB
Vue
Raw Normal View History

2024-05-17 23:35:44 +08:00
<template>
<view class="tree-content-compontent">
<view class="content-box" @click="expandFn">
<text class="box-text" @click.stop="toggleNodes(item)">{{ item.groupName }}</text>
<u-icon name="arrow-right" color="#D5D5D5" size="44" v-if="!expanded && item.children && item.children.length"></u-icon>
<u-icon name="arrow-down" color="#D5D5D5" size="44" v-if="expanded && item.children && item.children.length"></u-icon>
<!-- <image style="width:80rpx;height:80rpx;float:left" src="../../static/icon-down-black.png" mode="">
</image> -->
</view>
<view class="sub-component">
<view :class="expanded == true ? 'expandedStyle' : ''" v-if="item.children && item.children.length && expanded">
<tree-menu v-for="child in item.children" :key="child.id" :item="child" :treeIndex="treeIndex + 1" @clickItem="clickTreeItem"></tree-menu>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'TreeMenu',
props: ['item','treeIndex'],
data() {
return {
expanded: false,
};
},
methods: {
clickTreeItem(item){
console.log(item,777888)
uni.navigateTo({
url: './videoList?obj=' + JSON.stringify(item)
})
},
expandFn(){
this.expanded = !this.expanded;
},
toggleNodes(item) {
this.$emit('clickItem', item);
}
},
}
</script>
<style lang="scss" scoped>
.tree-content-compontent{
background: #FFFFFF;
.content-box{
display: flex;
align-items: center;
justify-content: start;
padding: 20rpx 36rpx;
position: relative;
// border-bottom: 2px solid #D6D6D6;
>text{
font-family: PingFang SC, PingFang SC;
font-weight: 400;
font-size: 32rpx;
color: #272D45;
margin-right: auto;
display: inline-block;
flex: 1;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
.expandedStyle{
margin-left: 40rpx;
}
}
</style>