# Vue 3 项目,安装最新版 Vant
npm i vant
安装rem适配 直接使用px就会转rem
$ npm install postcss postcss-pxtorem --save-dev
// postcss.config.js
module.exports = {
plugins: {
'postcss-pxtorem': {
rootValue: 37.5,
propList: ['*'],
},
},
};
postcss 简介
// ` px`转换为`rem`
. 转换{
字体大小: 16像素;//转换为1rem _
}
// `Px`或` PX`被 `postcss - px to rem` 忽略但仍被浏览器接受
. 忽略{
边框: 1 Px实心;//忽略_
b阶-宽度:2PX;//忽略_
}
main.ts 按需引入
import {
Form,
Field,
CellGroup,
Button,
Tabbar,
TabbarItem,
Swipe,
SwipeItem,
NoticeBar,
Image as VanImage,
Cell,
Icon,
Popup,
Picker,
PasswordInput,
Search,
PullRefresh,
List,
RadioGroup,
Radio,
} from 'vant'
import 'vant/lib/index.css'
按需引用才是王道