• html实现简单的目标树


    在这里插入图片描述

    <template>
        <div class="canvasBox"> 
            <!-- 父级的目标 -->
            <div v-if="objective.superObj.id" style="display:flex">
                <div class="objective_card_list">
                    {{objective.superObj.name}}
                </div> 
                <div style="width:100px; height:40px; border-bottom:1px solid #d9d9d9"></div> 
            </div>
            <!-- 当前目标 -->
            <div>
                <div class="objective_card_list" style="background-color:#f0f8ff">
                    {{objective.name}}
                </div>
            </div> 
            <!-- 子级目标 -->
            <div v-if="objective.subObj.length > 0">
                <div v-for="(subItem,subIndex) of objective.subObj" :key="subItem.id" style="display:flex">
                    <!-- 只有一个子目标 -->
                    <div v-if="subIndex==0 && objective.subObj.length == 1">
                        <div style="width:100px; height:40px; border-bottom:1px solid #d9d9d9"></div>
                    </div>
                    <!-- 多个子目标第一个目标 -->
                    <div v-if="subIndex==0 && objective.subObj.length > 1">
                        <div style="width:100px; height:40px; border-bottom:1px solid #d9d9d9"></div>
                        <div style="width:50px; height:60px; margin-left:auto; border-left:1px solid #d9d9d9"></div>
                    </div>
                    <!-- 多个子目标中间部分的目标 --> 
                    <div style="width:100px"  v-if="subIndex && subIndex != objective.subObj.length -1">
                        <div style="width:50px; height:40px; margin-left:auto; border-left:1px solid #d9d9d9; border-bottom:1px solid #d9d9d9;"></div>
                        <div style="width:50px; height:60px; margin-left:auto; border-left:1px solid #d9d9d9"></div>
                    </div>
                    <!-- 多个子目标中的最后一个目标 -->
                    <div style="width:100px" v-if="subIndex && subIndex == objective.subObj.length -1"> 
                        <div style="width:50px; height:40px; margin-left:auto; border-bottom:1px solid #d9d9d9; border-left:1px solid #d9d9d9"></div>
                    </div>
                    <div class="objective_card_list">
                        {{subItem.name}}
                    </div>
                </div>
            </div>
        </div>
    </template>
    
    <script>
    export default {
        data(){
            return{
                objective:{
                    name:'当前目标',
                    superObj:{
                        id:'101',
                        name:'父级目标',
                    },
                    subObj:[
                        {
                            id:"001",
                            name:'第一个子目标'
                        },
                        {
                            id:"002",
                            name:'第二个子目标'
                        },
                        {
                            id:"003",
                            name:'第三个子目标'
                        },
                        {
                            id:"004",
                            name:'第四个子目标'
                        }
                    ]
                }
            }
        }
    }
    </script>
    
    <style>
    .canvasBox{
        display: flex;
        justify-content: center;
        padding: 60px;
        min-height: 500px;
        border: 1px solid #000;
    }
    .objective_card_list{
        width: 200px;
        height: 80px;
        text-align: center;
        line-height: 80px;
        overflow: hidden;
        border: 1px solid #d9d9d9;
        border-radius: 2px;
        transition: ease all 0.5s;
        cursor: pointer; 
    } 
    </style>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
  • 相关阅读:
    [BUG] runtime network not ready: NetworkReady=false reason:NetworkPluginNotRead
    【Spring boot 拦截器 HandlerInterceptor】
    自动驾驶---OpenSpace之Hybrid A*规划算法
    【Flink读写外部系统】Flink异步访问外部系统_mysql
    高NA傅里叶显微镜单分子成像
    类的装饰器
    手写深度学习之优化器(SGD、Momentum、Nesterov、AdaGrad、RMSProp、Adam)
    8卡4090服务器适合用于transformer图像生成模型训练吗?速度怎么样?可以在windows下训练吗
    《Unix 网络编程》05:TCP C/S 程序示例
    HashMap高频面试题,让你掌握青铜回答与王者级回答,你值得拥有
  • 原文地址:https://blog.csdn.net/HTML5_student/article/details/125441641