feat: 回滚自适应导致的样式错误

pull/1/head
刘释隆 1 year ago
parent c4672fe334
commit 8755666c5d

@ -1,44 +0,0 @@
/**
* PostCSS 配置文件
*/
module.exports = {
// 配置要使用的 PostCSS 插件
plugins: {
// 配置使用 autoprefixer 插件
// 作用:生成浏览器 CSS 样式规则前缀
// VueCLI 内部已经配置了 autoprefixer 插件
// 所以又配置了一次,所以产生冲突了
// 'autoprefixer': { // autoprefixer 插件的配置
// 配置要兼容到的环境信息
// browsers: ['Android >= 4.0', 'iOS >= 8']
// },
// 配置使用 postcss-pxtorem 插件
// 作用:把 px 转为 rem
'postcss-pxtorem': {
// lib-flexible 的 REM 适配方案:把一行分为 10 份,每份就是十分之一
// 所以 rootValue 应该设置为你的设计稿宽度的十分之一
// 我们的设计稿是 750所以应该设置为 750 / 10 = 75
// 但是 Vant 建议设置为 37.5,为什么?因为 Vant 是基于 375 写的
// 所以必须设置为 37.5,唯一的缺点就是使用我们设计稿的尺寸都必须 / 2
// 有没有更好的办法?
// 如果是 Vant 的样式,就按照 37.5 来转换
// 如果是 我们自己 的样式,就按照 75 来转换
// 通过查阅文档,我们发现 rootValue 支持两种类型:
// 数字:固定的数值
// 函数:可以动态处理返回
// postcss-pxtorem 处理每个 CSS 文件的时候都会来调用这个函数
// 它会把被处理的 CSS 文件相关的信息通过参数传递给该函数
// file vant-button.css
// file : login.vue
mediaQuery: true, //媒体查询( @media screen 之类的)中不生效
// unitPrecision: 5, //保留rem小数点多少位
// selectorBlackList: [''], //则是一个对css选择器进行过滤的数组比如你设置为['fs']那例如fs-xl类名里面有关px的样式将不被转换这里也支持正则写法。
rootValue: 16,
// 配置要转换的 CSS 属性
// * 表示所有
propList: ['*']
}
}
}

@ -49,7 +49,6 @@
"@types/node": "^18.17.1",
"@types/sortablejs": "^1.15.7",
"@vitejs/plugin-vue": "^4.5.0",
"amfe-flexible": "^2.2.1",
"autoprefixer": "^10.4.13",
"core-js": "^3.32.0",
"dotenv": "^16.3.1",
@ -60,7 +59,6 @@
"less-loader": "^11.1.3",
"lint-staged": "^13.1.2",
"postcss": "^8.4.27",
"postcss-pxtorem": "^6.1.0",
"rimraf": "^4.2.0",
"sass": "^1.69.5",
"tailwindcss": "^3.3.3",

@ -45,16 +45,16 @@ const getThemeOverrides = computed(() => {
};
});
onMounted(() => {
window.addEventListener("resize", () => {
nextTick(() => {
const designWidth = 1440;
const rempPx = 16;
const scale = window.innerWidth / designWidth;
document.documentElement.style.fontSize = scale * rempPx + "px";
});
});
});
// onMounted(() => {
// window.addEventListener("resize", () => {
// nextTick(() => {
// const designWidth = 1440;
// const rempPx = 16;
// const scale = window.innerWidth / designWidth;
// document.documentElement.style.fontSize = scale * rempPx + "px";
// });
// });
// });
</script>
<template>

@ -5,7 +5,6 @@ import router, { setupRouter } from './router'
import { setupGlobalProperties, setupMousestrap, setupNaive, setupNaiveDiscreteApi, setupSvgIcon } from '@/plugins'
import { setupStore } from '@/store'
import 'virtual:svg-icons-register'
import 'amfe-flexible'
async function bootstrap() {
const app = createApp(App)

Loading…
Cancel
Save