笔者在这里推荐两个插件  

postcss-pxtorem、amfe-flexible

1、postcss-pxtorem 可以实现动态的将px转为rem单位(px to rem),笔者建议大家拖动窗口大小就可以看见效果哦。

//首先安装
yarn add postcss-pxtorem --dev

 

使用vue cli3/vue cli4 创建的,在项目根目录下有个postcss.config.js,打开在里面添加一下一行配置

//配置
plugins: { autoprefixer: {},
'postcss-pxtorem': { rootValue: 37.5, //这里是px转为rem的基准值,当字体为设置14px时,在通用手机尺寸上显示为14px。 propList: ['*'] } }

2、amfe-flexible 页面响应式设计

//首先安装
yarn add amfe-flexible

//main.js中引入
import 'amfe-flexible'

接下来,就可以在页面上使用px单位了,在手机端可以自动适应。

相关文章:

  • 2021-08-13
  • 2022-12-23
  • 2021-04-18
  • 2022-01-09
  • 2022-01-09
  • 2022-12-23
  • 2021-06-29
  • 2022-12-23
猜你喜欢
  • 2021-10-30
  • 2022-02-02
  • 2021-09-15
  • 2021-05-17
  • 2022-12-23
  • 2021-08-29
  • 2021-07-23
相关资源
相似解决方案