• vue首页组件切换


    结构如下

    代码如下:

    <template>
        <div id="page">
            <div style=" 100%" class="flex-container column">
    
                <div class="item one" @click="clickChart('1')" style="transform: translate(-38.4%, -24.5%) scale(0.23)">
                    <Pie ref="pie"></Pie>
                </div>
                <div class="item two" @click="clickChart('2')" style="transform: translate(-38.4%, 14.5%) scale(0.23)">
                    <WorldMap ref="worldMap"></WorldMap>
                </div>
                <div class="item three" style="transform: translate(-18.6%, -28.5%) scale(0.33);height: 20%; 160%">
                    <Home></Home>
                </div>
                // active 很关键 别写漏掉了
                <div class="item four active" @click="clickChart('4')" style="transform: translate(0%, -9.5%) scale(0.55);">
                    <Geo ref="geo"></Geo>
                </div>
                <div class="item five" @click="clickChart('5')" style="transform: translate(38.29%, -24.5%) scale(0.23);">
                    <Pile ref="pile"></Pile>
                </div>
                <div class="item six" @click="clickChart('6')" style="transform: translate(38.29%, 14.5%) scale(0.23);">
                    <Gauge></Gauge>
                </div>
            </div>
        </div>
    </template>
    <script>
        import Geo from '@/components/Geo'
        import Pile from '@/components/Pile'
        import Pie from '@/components/Pie'
        import Gauge from '@/components/Gauge'
        import WorldMap from '@/components/WorldMap'
        import Home from '@/components/Home'
    
        export default {
    
            components: {
                Geo,
                Pie,
                Pile,
                Gauge,
                WorldMap,
                Home
            },
    
            data() {
                return {iconDisplay: '4'}
            },
            methods: {
                clickChart(clickIndex) {
                    let activeItem = document.querySelector('.flex-container .active')
                    let activeIndex = activeItem.dataset.order
                    let clickItem = this.items[clickIndex - 1]
                    if (activeIndex === clickIndex) {
                        return
                    }
                    activeItem.classList.remove('active')
                    clickItem.classList.add('active')
                    this._setStyle(clickItem, activeItem)
                    this.iconDisplay = clickIndex
                }, _setStyle(el1, el2) {
                    let transform1 = el1.style.transform
                    let transform2 = el2.style.transform
                    el1.style.transform = transform2
                    el2.style.transform = transform1
                }
            }
        }
    </script>
    <style scoped> .active {
        height: 110%;
         100%;
        margin-left: 10px;
        line-height: 300px;
        background-color: rgba(47, 136, 165, 0.35) !important;
        z-index: 9;
    }
    
    .item {
        padding: 0px;
        margin: 0px;
        position: absolute;
        transform: scale(0.33);
        text-align: center;
        transition: all 0.8s;
        background: rgba(43, 94, 121, 0.3);
    }
    
    .flex-container.column {
        position: relative;
        height: 100%;
         100%;
        overflow: hidden;
        box-sizing: content-box;
    } </style>
     
  • 相关阅读:
    RecyclerView,ListView first item get focus
    一种粗暴快速的Android全屏幕适配方案(转)
    谈谈单元测试之(一):为什么要进行烦人的单元测试(转)
    SCIgen与野鸡期刊的梗
    百度搜索仍然是【最快解决工作问题的方法】
    搭建minima主题的github博客网站
    本科期间的第一个专利:改卷筒的故事
    学习消费思维的【贫穷与富有】
    我的联系方式
    学习 GitHub 有什么好处?
  • 原文地址:https://www.cnblogs.com/JonaLin/p/11854752.html
Copyright © 2020-2023  润新知