结构如下

代码如下:

<template>
<div id="page">
<div style="width: 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%;width: 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: ''}
},
methods: {
clickChart(clickIndex) {
let activeItem = document.querySelector('.flex-container .active')
let activeIndex = activeItem.dataset.order
let clickItem = this.items[clickIndex - ]
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: %;
width: %;
margin-left: 10px;
line-height: 300px;
background-color: rgba(, , , 0.35) !important;
z-index: ;
} .item {
padding: 0px;
margin: 0px;
position: absolute;
transform: scale(0.33);
text-align: center;
transition: all .8s;
background: rgba(, , , 0.3);
} .flex-container.column {
position: relative;
height: %;
width: %;
overflow: hidden;
box-sizing: content-box;
} </style>

vue首页组件切换的更多相关文章

  1. vue动态组件切换(选项卡)

    vue的动态组件 <template :is='变量'></template> 可以通过改变变量,来改变template的替换内容.达到选项卡的功能 如果想要切换保持不重新创建 ...

  2. vue实现组件切换的两种方式

    <!DOCTYPE html> <html> <head> <title>组件的切换</title> <meta charset=&q ...

  3. vue.js(17)--vue的组件切换

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. vue 实现tab切换动态加载不同的组件

    vue 实现tab切换动态加载不同的组件 使用vue中的is特性来加载不同的组件.具体看如下代码:这个功能对于vue比较复杂的页面可以使用上,可以把一个页面的功能拆分出来,使代码更简单.使用方式具体看 ...

  5. Vue系列之 => 组件切换

    组件切换方式一 <!DOCTYPE html> <html lang="en"> <head> <meta charset="U ...

  6. AntDesign vue学习笔记(四)使用组件切换

    同样实现上一篇功能, 改为使用组件切换,实现方法如下 1.修改MainFrm中的<router-view/>如下代码 2.注册局部组件 export default { name: 'Ma ...

  7. 组件切换方式(Vue.js)

    这里,我用一个注册登录两组件的切换实例来演示: 切换方式一 <!DOCTYPE html> <html lang="zh-CN"> <head> ...

  8. Vue学习之组件切换及父子组件小结(八)

    一.组件切换: 1.v-if与v-else方式: <!DOCTYPE html> <html lang="en"> <head> <met ...

  9. Vue学习笔记【24】——Vue组件(组件切换)

    使用flag标识符结合v-if和v-else切换组件 页面结构:(缺点:只适用于两个组件间切换,不适合多个)  <div id="app">    <input ...

随机推荐

  1. Vue项目搭建流程

    记录一下vue项目的搭建流程. 1.安装node.npm 下载地址为:https://nodejs.org/en/ 设置环境变量,命令行分别输入: node -v   npm -v  查看安装是否成功 ...

  2. 11、组件注册-使用FactoryBean注册组件

    11.组件注册-使用FactoryBean注册组件 package org.springframework.beans.factory; import org.springframework.lang ...

  3. Dynamic Data linq to SQL Web Application

    微软提供了一个数据驱动网站模板,可以自动生成CRUD页面,使用过程中碰到些问题 1.首先是如何应用,只需要创建个context并且在Global.asax里面加入下面这一句就可以了 DefaultMo ...

  4. 转载:appium踩过的坑

    原文地址:http://blog.csdn.net/wirelessqa/article/details/29188665 自己的操作:由于在window上安装appium时,报各种错误:所以选择在u ...

  5. 做uart 实验时,run configure 只能选择jtag_uart 而没有uart

    使用的是nios ii 13 版本.直接在nios 软件上运行时程序能够执行,其中已经配置了stdin stderr stdout为jtag_uart.run configure 里面的byte st ...

  6. 牛客练习赛55 E-树 树形DP

    题意 你有一颗大小为\(n\)的树,点从\(1\)到\(n\)标号. 设\(dis⁡(x,y)\)表示\(x\)到\(y\)的距离. 求\(\sum_{i=1}^{n}\sum_{j=1}^{n}di ...

  7. Print工具类

    这篇文章已经废弃. 实际开发中,打印信息只会用日志框架(Log4j2). 受到Thinking in Java中静态引入(import static)的启发, Deolin也打算写一个方便自己的工具类 ...

  8. 7.26T2某不科学的迷你激光炮

    题目描述 身为课代表的她,下课总愿意帮老师发作业.老师的作业好多好多啊,一天 下来,她下课休息时间也无几了…… 要是天花板上有一只激光炮该多好啊!把作业塞到激光炮里面,轰——一排 同学该都拿到作业了吧 ...

  9. c++ 生成容器元素生成随机数

    // random_shuffle example #include <iostream> // cout #include <algorithm> // random_shu ...

  10. Exception in thread "main" java.util.ConcurrentModificationException解决方案

    我想判断一个集合里面有没有"world"这个元素,如果有,我就添加一个"javaee"元素, 当时的做法是: public class ListIterator ...