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 ...
随机推荐
- Educational Codeforces Round 74 (Rated for Div. 2) C. Standard Free2play
链接: https://codeforces.com/contest/1238/problem/C 题意: You are playing a game where your character sh ...
- PHP mmysqli_affected_rows(connection);函数
mysqli_affected_rows(); 函数返回前一次 MySQL 操作所影响的记录行数. mysqli_affected_rows(connection); connection 必需.规定 ...
- mysql远程服务密码修改
GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root"; FLUSH PRIVILEGE ...
- learning express step(四)
learning express route function const express = require('express'); const app = express(); app.get(' ...
- Cash Machine (POJ 1276)(多重背包——二进制优化)
链接:POJ - 1276 题意:给你一个最大金额m,现在有n种类型的纸票,这些纸票的个数各不相同,问能够用这些纸票再不超过m的前提下凑成最大的金额是多少? 题解:写了01背包直接暴力,结果T了,时间 ...
- Simple Problem with Integers(POJ 3486)
A Simple Problem with Integers Time Li ...
- sick 激光
sick10:TiM561-2050101https://www.sick.com/cn/zh/detection-and-ranging-solutions/2d-lidar-/tim5xx/tim ...
- ImportError: No module named pytz
xxx@hostname:/opt/xx/cc$ python manage.py runserver Traceback (most recent call last): File , in < ...
- mvc partialView断点调试问题
mvc中的partialview 在前端f12调试时,默认看不到代码的. 在Js中加上debugger; 调试时会走到断点,多出个VM打头的局部视图页面.
- Heat map 绘图神奇
https://study.163.com/provider/400000000398149/index.htm?share=2&shareId=400000000398149(博主视频教学主 ...