-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
viewports适配, vant的参考尺寸是 375, 设计稿的尺寸是750, 如何在vite配置postcss-px-to-viewport #9338
Comments
@chenjiahan 这中写法只能适用用 px2rem, postcss-px-to-viewport 该怎么 配置呢 |
px-to-viewport 没支持,可以带他们提需求 |
px2rem 使用 lib-flexible 有坑, 目前遇到的 华为P40,html 的宽度 大于屏幕宽度 |
生产上遇到过需要配置px2vh的,其实百度也能搜到这个 const path = require('path');
module.exports = ({ file }) => {
const designWidth = file.dirname.includes(path.join('node_modules', 'vant')) ? 375 : 750;
return {
plugins: {
'postcss-px-to-viewport': {
unitToConvert: 'px',
viewportWidth: designWidth, //设计图视口宽度 按IOS标准点@1x
unitPrecision: 3,
propList: ['*'],
viewportUnit: 'vw',
fontViewportUnit: 'vw',
selectorBlackList: ['.ignore'],
minPixelValue: 1,
mediaQuery: false,
replace: true,
exclude: [],
landscape: false,
landscapeUnit: 'vw',
landscapeWidth: 1628 //视口高度
}
}
};
}; |
这个是 webpack 构建的 不是vite |
解决了吗 |
请问现在有vite适配vant的postcss-px-to-viewport方案了吗 |
`// /** vite中配置postcss-px-to-viewport 引入postcsspxtoviewport export default defineConfig({ |
可参考该位大神的内容:https://juejin.cn/post/6961737808339795975 |
使用cnjm-postcss-px-to-viewport这个插件 |
你好,请使用下面的链接创建 issue 以帮助我们更快的排查问题,不规范的 issue 会被关闭,感谢配合。
http://vant-contrib.gitee.io/vant-issue-generater
Please use the link below to create a new issue, the non-standard issue will be closed.
https://youzan.github.io/vant-issue-generater
The text was updated successfully, but these errors were encountered: