日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 前端技术 > vue >内容正文

vue

vue项目使用rem让页面字体fontsize自适应

發(fā)布時間:2024/3/24 vue 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 vue项目使用rem让页面字体fontsize自适应 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

頁面字體fontsize自適應(yīng)(在頁app.vue頁面添加)

將css里面的html和body的font-size都設(shè)置成62.5%然后10px=1rem這樣寫頁面

<script> const rootHeight = 940; </script>mounted() {let html = document.getElementsByTagName('html');html[0].style.fontSize = `${Math.max(document.body.clientHeight, 768) / rootHeight * 62.5}%`;window.onresize = () => {html[0].style.fontSize = `${Math.max(document.body.clientHeight, 768) / rootHeight * 62.5}%`;}},const rootWidth = 1920 onMounted(() => {const html = document.getElementsByTagName('html')html[0].style.fontSize = `${Math.max(document.body.clientWidth, 1024) / rootWidth * 62.5}%`}window.onresize = () => {const html = document.getElementsByTagName('html')html[0].style.fontSize = `${Math.max(document.body.clientWidth, 1024) / rootWidth * 62.5}%`}



echarts圖表的自適應(yīng)(不同分辨率下的顯示)

// echarts配置中 * 圖表這里的option.js 里面的配置 字號 間距什么的都加了*wScale 這個 import Vue from "vue" let wScale = Vue.prototype.$wScale;itemWidth: 50 * wScale , wdth: 50 * wScale , fontSize: 16 * wScale ,// main.js import "./utils/scale";// scale.js import Vue from "vue" const fullWidth = 1920,fullHeight = 940; // 長寬屏幕比 Vue.prototype.$wScale = document.body.clientWidth / fullWidth Vue.prototype.$hScale = document.body.clientWidth / fullHeight

總結(jié)

以上是生活随笔為你收集整理的vue项目使用rem让页面字体fontsize自适应的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。