Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of adapting to vue large screen display?

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces "what is the method of vue large screen display adaptation". In daily operation, I believe that many people have doubts about what is the method of vue large screen display adaptation. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "what is the method of vue big screen display adaptation?" Next, please follow the editor to study!

The details are as follows

Create a file for the 1.utils folder: cv the following code

Export function useIndex (appRef) {/ / * appRef points to the outermost container / / * timing function let timer = null / / * default scaling value const scale = {width:'1' Height:'1'} / / * Design size (px) const baseWidth = 1920 const baseHeight = 1080 / / * ratio to be maintained (default 2) / / const baseProportion = parseFloat ((baseWidth / baseHeight). ToFixed (5) const baseProportion = 2 const calcRate = () > {/ / current aspect ratio const currentRate = parseFloat ((window.innerWidth / window.innerHeight). ToFixed (5) if (appRef)) {if (currentRate > baseProportion) {/ / indicates wider scale.width = ((window.innerHeight * baseProportion) / baseWidth) .tofixed (5) scale.height = (window.innerHeight / baseHeight) .tofixed (5) appRef.style.transform = `scale (${scale.width}) ${scale.height}) translate (- 50%,-50%) `} else {/ / means higher scale.height = ((window.innerWidth / baseProportion) / baseHeight) .tofixed (5) scale.width = (window.innerWidth / baseWidth) .tofixed (5) appRef.style.transform = `scale (${scale.width}, ${scale.height}) translate (- 50%) -50%) `}} const resize = () = > {clearTimeout (timer) timer = setTimeout (() = > {calcRate ()}, 200)} / / change the window size and redraw const windowDraw = () = > {window.addEventListener ('resize', resize)} return {appRef, calcRate, windowDraw}}

2.app.vue structure style

Import {useIndex} from'@ / utils/utilsDram.js'export default {mounted () {const {calcRate, windowDraw} = useIndex (this.$refs.appRef) calcRate () windowDraw ()}. Main {color: # d3d6dd; width: 1920px; height: 1080px; position: absolute; top: 50%; left: 50%; transform: translate (- 50%,-50%); transform-origin: left top;. Layout-container {width: 100%; height: 100% }}

3. Font size box width directly set px regardless of zoom in or out is the original appearance, the basic page size will not be too far, the following picture is the effect of page magnification of 500x

At this point, on the "vue large screen display adaptation method is what is the end of the study, I hope to be able to solve your doubts." The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report