123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <template>
- <div>
- <keep-alive>
- <router-view v-if="$route.meta.keepAlive"></router-view>
- </keep-alive>
- <router-view v-if="!$route.meta.keepAlive"></router-view>
- </div>
- </template>
- <script>
- import $ from 'jquery'
- export default {
- name: "app",
- created() { },
- mounted() {
- let width=$("body").width();
- console.log(width)
- if(width>=1200){
- let fontsize=width/1920*40;//fontsize为当前屏幕的基数字体,相对于设计稿计算得到的。
- $("html").css("font-size",`${fontsize}px`)
- }
- if(width<=750){
- let fontsize=width/400*40;
- $("html").css("font-size",`${fontsize}px`)
- }
- //当加载页面的时候设置生效
- window.onresize = () => {
- return (() => {
- let width=$("body").width();
- if(width>=1200){
- let fontsize=width/1920*40;
- $("html").css("font-size",`${fontsize}px`)
- }
- if(width<=750){
- let fontsize=width/400*40;
- $("html").css("font-size",`${fontsize}px`)
- }
- })()
- }
- }
- };
- </script>
|