程序员开发实例大全宝库

网站首页 > 编程文章 正文

vue-cli4.x 如何配置 rem 移动端配置

zazugpt 2024-08-16 06:50:05 编程文章 64 ℃ 0 评论

第一步在创建好的项目中安装 amfe-flexible postcss-pxtorem

yarn add postcss-pxtorem@5.1.1
yarn add amfe-flexible

postcss-pxtorem 安装5.1.1 版本 因为最新版本打包时可能会出错!


第二步在main.js中引入amfe-flexible


第三步在vue.config.js中配置css

css: {
	loaderOptions: {
		postcss: {
			plugins: [
				require('postcss-pxtorem')({ // 把px单位换算成rem单位
				rootValue: 132, // 换算的基数(设计图750的根字体为75)
				propList: ['*']
 			})
 		]
 	}
 	},
 },


完成后需要重新编译才能生效!!

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表