各位程序员,我用uniapp开发小程序遇到这样的数据转成树状图。大家有什么插件或者例子的吗。
https://ext.dcloud.net.cn/plugin?id=3375
<template>
<view class="content">
<view class="main">
<view class="root">
乡村振兴行业
<view class="root-line">
<view class="root-line-content">
上游支柱产业
</view>
</view>
<view class="root-line1">
<view class="root-line2">
<view class="root-line2-content">
上游支柱产业
</view>
</view>
<view class="root-line3">
<view class="root-line3-content">
上游支柱产业
</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
onLoad() {
},
onShow() {
},
methods: {
}
}
</script>
<style scoped>
.main {
text-align: center;
position: relative;
}
.root {
display: inline-block;
border: 1px solid #ccc;
width: 120px;
height: 30px;
line-height: 30px;
text-align: center;
border-radius: 20px;
position: relative;
}
.root-line {
position: absolute;
left: 50%;
margin-left: -1px;
top: 36px;
height: 80px;
width: 2px;
background-color: #f00;
}
.root-line::before{
content: "";
position: absolute;
left: 0;
margin-left: -2px;
top: -6px;
width: 4px;
height: 4px;
border: 1px solid #f0f;
border-radius: 50%;
}
.root-line::after{
content: "";
position: absolute;
left: 0;
margin-left: -2px;
bottom: -6px;
width: 4px;
height: 4px;
border: 1px solid #f0f;
border-radius: 50%;
}
.root-line-content{
position: absolute;
top: 90px;
left: 50%;
margin-left: -50px;
width: 100px;
height: 60px;
line-height: 60px;
background-color: #ccc;
font-size: 14px;
border-radius: 12px;
}
.root-line1{
position: absolute;
left: 50%;
margin-left: -120px;
top: 80px;
height: 2px;
width: 240px;
background-color: #f00;
}
.root-line2{
position: absolute;
left: 0;
top: 0;
height: 40px;
width: 2px;
background-color: #f00;
}
.root-line3{
position: absolute;
right: 0;
top: 0px;
height: 40px;
width: 2px;
background-color: #f00;
}
.root-line2::after{
content: "";
position: absolute;
left: 0;
bottom: -4px;
margin-left: -2px;
width: 4px;
height: 4px;
border: 1px solid #f0f;
border-radius: 50%;
}
.root-line2-content{
position: absolute;
top: 46px;
left: 50%;
margin-left: -50px;
width: 100px;
height: 60px;
line-height: 60px;
background-color: #ccc;
font-size: 14px;
border-radius: 12px;
}
.root-line3::after{
content: "";
position: absolute;
left: 0;
bottom: -4px;
margin-left: -2px;
width: 4px;
height: 4px;
border: 1px solid #f0f;
border-radius: 50%;
}
.root-line3-content{
position: absolute;
top: 46px;
left: 50%;
margin-left: -50px;
width: 100px;
height: 60px;
line-height: 60px;
background-color: #ccc;
font-size: 14px;
border-radius: 12px;
}
</style>
【treeY纵轴树状图支持任意修改,添加数据,渲染数据,无限级分类 - DCloud 插件市场】https://ext.dcloud.net.cn/plugin?id=3375
楼上两个方案都可以.要么用插件,要么用css自己实现点线.类比 物流信息界面.