Commit 40db9b73 authored by 毛线's avatar 毛线

高度自适应

parent 388daca5
<template> <template>
<div class="root"> <div :class="(isMoblie && marginSceen) ? 'mobile' : ''" class="root">
<div :style="style" :class="{ margin : marginSceen }" class="sceen"> <div :style="style" :class="{ margin : marginSceen }" class="sceen">
<nuxt /> <nuxt />
</div> </div>
...@@ -18,24 +18,26 @@ export default { ...@@ -18,24 +18,26 @@ export default {
data() { data() {
return { return {
zoom: 1, zoom: 1,
deg: 0, // 旋转角度
right: 0,
position: 'relative',
marginSceen: false, marginSceen: false,
isMoblie: false, isMoblie: false,
scale: 1, scale: 1,
top: 0,
} }
}, },
computed: { computed: {
style() { style() {
const style = {} const style = {}
const { zoom, deg, right, position, scale } = this const { zoom, isMoblie, marginSceen, top, } = this
style.zoom = zoom style.zoom = zoom
// style.transform = `rotate(${deg}deg) scale(1.72)`
style.transform = `rotate(${deg}deg) scale(${scale})`
style.right = `${right}px` if (isMoblie) {
style.position = position if (!marginSceen) {
style.transform = `rotate(90deg) scale(1.72)`
} else {
style.transformOrigin = `0px 0px 0px`
style.transform = `matrix(0, 1, -1, 0, ${608 + top}, 0)`
}
}
return style return style
}, },
}, },
...@@ -62,6 +64,7 @@ export default { ...@@ -62,6 +64,7 @@ export default {
} }
if (innerWidth > 750) { if (innerWidth > 750) {
this.initPcSceen() this.initPcSceen()
this.isMoblie = false
} else { } else {
this.initMobileSceen() this.initMobileSceen()
} }
...@@ -81,73 +84,26 @@ export default { ...@@ -81,73 +84,26 @@ export default {
// this.SetInnerWidth(innerWidth) // this.SetInnerWidth(innerWidth)
// this.SetInnerHeight(innerHeight) // this.SetInnerHeight(innerHeight)
this.zoom = zoom this.zoom = zoom
this.deg = 0
this.right = 0
this.position = 'relative'
this.isMoblie = false this.isMoblie = false
this.scale = 1
}, },
// 初始化移动端屏幕 // 初始化移动端屏幕
initMobileSceen() { initMobileSceen() {
let zoom = 1 let zoom = 1
const { innerWidth, innerHeight } = window const { innerWidth, innerHeight } = window
// if (innerWidth / innerHeight > 1080 / 608) {
// zoom = window.innerHeight / 608
// this.marginSceen = false
// } else {
// zoom = window.innerWidth / 1080
// this.marginSceen = false
// }
if (innerHeight / innerWidth > 1080 / 608) { if (innerHeight / innerWidth > 1080 / 608) {
zoom = window.innerWidth / 1080 zoom = window.innerWidth / 1080
console.log(1)
this.SetZoom(zoom) this.SetZoom(zoom)
this.zoom = zoom this.zoom = zoom
this.deg = 90 this.marginSceen = false
this.position = 'relative'
this.isMoblie = true
this.right = 0
this.scale = 1.72
} else { } else {
zoom = window.innerHeight / 1080 zoom = window.innerHeight / 1080
console.log(2)
this.SetZoom(zoom) this.SetZoom(zoom)
this.zoom = zoom this.zoom = zoom
this.deg = 90
this.position = 'relative'
this.isMoblie = false
this.right = 0
this.scale = 1
// this.initMobileSceen2()
}
// this.position = 'absolute'
},
// 初始化移动端屏幕
initMobileSceen2() {
let zoom = 1
let right = 0
const { innerWidth, innerHeight } = window
if (innerHeight / innerWidth > 1080 / 608) {
console.log(1)
zoom = window.innerWidth / 608
this.marginSceen = false
right = 363
} else {
console.log(2)
zoom = window.innerHeight / 1080
this.marginSceen = true this.marginSceen = true
const top = (innerWidth - (608 / 1080) * innerHeight)
right = (1080 / window.innerWidth * 200) - innerHeight / 0.5 + 608 * 2 this.top = top
} }
this.isMoblie = true
this.SetZoom(zoom)
this.zoom = zoom
this.right = right
this.deg = 90
this.position = 'absolute'
this.scale = 1
}, },
}, },
} }
...@@ -165,6 +121,15 @@ export default { ...@@ -165,6 +121,15 @@ export default {
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
background: black; background: black;
&.mobile {
justify-content: initial;
.sceen {
&.margin {
margin-left: inherit;
margin-right: inherit;
}
}
}
} }
.sceen { .sceen {
width: 1080px; width: 1080px;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment