3 changed files with 99 additions and 41 deletions
@ -0,0 +1,59 @@ |
|||
<template> |
|||
<div class="g-app"> |
|||
<div class="g-bd" :style="bdStyle"> |
|||
<slot></slot> |
|||
</div> |
|||
</div> |
|||
</template> |
|||
<script> |
|||
export default { |
|||
data() { |
|||
return { |
|||
clientHeight: document.documentElement.clientHeight, |
|||
clientWidth: document.documentElement.clientWidth, |
|||
}; |
|||
}, |
|||
|
|||
components: {}, |
|||
computed: { |
|||
bdStyle() { |
|||
const { clientHeight, clientWidth } = this; |
|||
console.log("clientHeight", clientHeight); |
|||
const scale = clientWidth / 1920; |
|||
const height = clientHeight / scale; |
|||
const top = (clientHeight - height) / 2; |
|||
const left = (clientWidth - 1920) / 2; |
|||
return { |
|||
transform: `scale(${scale})`, |
|||
height: `${height}px`, |
|||
left: `${left}px`, |
|||
top: `${top}px`, |
|||
}; |
|||
}, |
|||
}, |
|||
created() {}, |
|||
mounted() { |
|||
window.onresize = () => { |
|||
this.clientHeight = document.documentElement.clientHeight; |
|||
this.clientWidth = document.documentElement.clientWidth; |
|||
}; |
|||
}, |
|||
|
|||
methods: {}, |
|||
}; |
|||
</script> |
|||
|
|||
<style lang="scss" scoped> |
|||
.g-app { |
|||
position: absolute; |
|||
// width: 1920px; |
|||
width: 100%; |
|||
height: 100vh; |
|||
overflow: hidden; |
|||
} |
|||
|
|||
.g-bd { |
|||
position: absolute; |
|||
width: 1920px; |
|||
} |
|||
</style> |
|||
Loading…
Reference in new issue