vue3使用postcss-px2rem 文心快码BaiduComate 在Vue 3项目中使用postcss-px2rem插件可以方便地将CSS中的px单位转换为rem单位,以适应不同屏幕尺寸的设备。下面是详细的步骤: 1. 安装postcss-px2rem插件 首先,你需要在Vue 3项目中安装postcss-px2rem插件。你可以使用npm或yarn进行安装: bash npm install postcss-...
个人在使用lib-flexible插件时,感觉没hotcss友好, lib-flexible在页面打开的时候,内容渲染完了才在HTML根上添加适配,这样页面会重新渲染一次,导致内容从大变小,或从小变大这样的BUG。 而hotcss就没这个问题。 接下来要安装换算PX换算REM插件 cnpm install postcss-px2rem --save 然后在 vue.config.js加入: module....
// import "@/assets/css/common.less"; Vue.config.productionTip = false; Vue.prototype.wx_config = wxConfig; new Vue({ router, render: h => h(App) }).$mount("#app"); 然后配合postcss-px2rem进行自动转换rem,配置代码如下 module.exports = { css: { // 配置css模块 loaderOptions: { /...
npm install postcss-pxtorem -S 2. 在vue.config.js 中添加 module.exports = { lintOnSave: true, css: { loaderOptions: { postcss: { plugins: [ require('postcss-pxtorem')({ rootValue : 37.5, // 换算的基数 propList : ['*'], }), ] } } }, } 使用postcss-px2rem 1. 安装 postcss-p...