在uni-app框架中使用rem(h5和微信小程序)

2020-12-28  本文已影响0人  小雨喜欢大晴天

将在学习uni-app过程中遇到的问题记录一下:

1.rem根元素字号适配

//main.js

let fontSize = '100px';
const res = uni.getSystemInfoSync();
if(res.screenWidth < 750){//根据屏幕宽度进行适配
      fontSize = 100 * (res.screenWidth / 750) + 'px';
}
Vue.prototype.$footFontSize = fontSize;
//page.vue

<template>
  <page-mate :root-foot-size="footSize"></page-mate>
  <div>..</div>
</template>

<script>
    export default {
        data() {
            return {
                footSize: this.$rootFontSize,
            }
        }
    }
</script>

注意:<page-meta>需要放在页面的第一个标签。

问题汇总:

1.在uni-app框架中使用rem(h5和微信小程序)
2.index.html的设置

上一篇 下一篇

猜你喜欢

热点阅读