vue首页组件切换
结构如下

代码如下:
<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首页组件切换的更多相关文章
- vue动态组件切换(选项卡)
vue的动态组件 <template :is='变量'></template> 可以通过改变变量,来改变template的替换内容.达到选项卡的功能 如果想要切换保持不重新创建 ...
- vue实现组件切换的两种方式
<!DOCTYPE html> <html> <head> <title>组件的切换</title> <meta charset=&q ...
- vue.js(17)--vue的组件切换
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- vue 实现tab切换动态加载不同的组件
vue 实现tab切换动态加载不同的组件 使用vue中的is特性来加载不同的组件.具体看如下代码:这个功能对于vue比较复杂的页面可以使用上,可以把一个页面的功能拆分出来,使代码更简单.使用方式具体看 ...
- Vue系列之 => 组件切换
组件切换方式一 <!DOCTYPE html> <html lang="en"> <head> <meta charset="U ...
- AntDesign vue学习笔记(四)使用组件切换
同样实现上一篇功能, 改为使用组件切换,实现方法如下 1.修改MainFrm中的<router-view/>如下代码 2.注册局部组件 export default { name: 'Ma ...
- 组件切换方式(Vue.js)
这里,我用一个注册登录两组件的切换实例来演示: 切换方式一 <!DOCTYPE html> <html lang="zh-CN"> <head> ...
- Vue学习之组件切换及父子组件小结(八)
一.组件切换: 1.v-if与v-else方式: <!DOCTYPE html> <html lang="en"> <head> <met ...
- Vue学习笔记【24】——Vue组件(组件切换)
使用flag标识符结合v-if和v-else切换组件 页面结构:(缺点:只适用于两个组件间切换,不适合多个) <div id="app"> <input ...
随机推荐
- Mysql批量更新的一个坑-&allowMultiQueries=true允许批量更新(转)
实际上,我们经常会遇到这样的需求,那就是利用Mybatis批量更新或者批量插入,但是,实际上即使Mybatis完美支持你的sql,你也得看看你说操作的数据库是否支持,而阿福,最近就遇到这样的一个坑. ...
- 【leetcode】1240. Tiling a Rectangle with the Fewest Squares
题目如下: Given a rectangle of size n x m, find the minimum number of integer-sided squares that tile th ...
- C#读取App.config/Web.config
读取需要添加 System.Configuration 引用, 两种方式添加: 1:.NETFramework程序可以在引用右击添加引用,然后添加System.Configuration 2:引入Nu ...
- AtCoder Beginner Contest 116 D - Various Sushi 【贪心+栈】
Problem Statement There are NN pieces of sushi. Each piece has two parameters: "kind of topping ...
- 【题解】[Noip2010]机器翻译-C++
题目Description小晨的电脑上安装了一个机器翻译软件,他经常用这个软件来翻译英语文章.这个翻译软件的原理很简单,它只是从头到尾,依次将每个英文单词用对应的中文含义来替换.对于每个英文单词,软件 ...
- oracle自连接
自连接:通过表的别名,将同一张表视为多张表 select e.ename 员工姓名,b.ename 老板姓名 from emp e,emp b where e.mgr=b.empno; 注:自连接不适 ...
- windows游戏编程X86 32位保护模式下的内存管理概述(二)
本系列文章由jadeshu编写,转载请注明出处.http://blog.csdn.net/jadeshu/article/details/22448323 作者:jadeshu 邮箱: jades ...
- 哈希表(hash table)基础概念
哈希是什么 引入:我们在学习数组的时候,使用数组元素的下标值即可访问到该元素,所花费的时间是O(1),与数组元素的个数n没有关系,这就是哈希方法的核心思想. 哈希方法:以关键值K为自变量,通过一定的函 ...
- Python——装饰器(Decorator)
1.什么是装饰器? 装饰器放在一个函数开始定义的地方,它就像一顶帽子一样戴在这个函数的头上.和这个函数绑定在一起.在我们调用这个函数的时候,第一件事并不是执行这个函数,而是将这个函数做为参数传入它头顶 ...
- IDEA配置Hadoop开发环境&编译运行WordCount程序
有关hadoop及java安装配置请见:https://www.cnblogs.com/lxc1910/p/11734477.html 1.新建Java project: 选择合适的jdk,如图所示: ...