当前位置:网站首页>Px2rem loader converts PX into REM and adapts to mobile vant UI and other frameworks
Px2rem loader converts PX into REM and adapts to mobile vant UI and other frameworks
2022-07-26 12:55:00 【songywaa】
A brief description
Recently, I tried several mobile terminals ui frame , Find out vant-ui Not bad ;
But there's a problem , Namely vant-ui The unit is px, We need to convert it into rem;
Specific implementation method
1. download lib-flexible
It uses vue-cli+webpack, adopt npm To install
npm i lib-flexible --save
2. introduce lib-flexible
stay main.js Introduction in lib-flexible
import 'lib-flexible/flexible'
3. Set up meta label
adopt meta label , Set the device width and scaling
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
4. install px2rem-loader
npm install px2rem-loader
5. To configure px2rem-loader
This is an important step ~~
stay build Found in file util.js, take px2rem-loader Add to cssLoaders in , Such as :
const px2remLoader = {
loader: 'px2rem-loader',
options: {
remUnit: 75 // Set up here html Root font ,vant-UI The official root font size of is 37.5
}
}
meanwhile , stay generateLoaders Method to add px2remLoader
function generateLoaders (loader, loaderOptions) {
const loaders = options.usePostCSS ? [cssLoader, postcssLoader, px2remLoader] : [cssLoader, px2remLoader]
...
...
...
}
6. After configuration , Just restart the service , It is automatically converted to rem 了
npm run dev
After reboot , Viewing the units in the browser has become rem 了 ;
边栏推荐
- Who is responsible for the problems of virtual idol endorsement products? And listen to the lawyer's analysis
- 0基础编程资源大全(先收藏~慢慢看~)
- The.Net webapi uses groupname to group controllers to render the swagger UI
- Huawei ultra fusion fusioncube solution notes
- 0 basic programming resources (collect first ~ read slowly ~)
- 腾讯云与智慧产业事业群(CSIG)调整组织架构,成立数字孪生产品部
- mqtt send receive
- Backtracking - question 51 Queen n -- a classic backtracking problem that must be overcome
- The map function counts the number of occurrences of characters
- 华为年内二度招聘“天才少年”;540万Twitter账号信息泄露,卖价3万美元;谷歌解雇了相信AI有意识的工程师|极客头条...
猜你喜欢

Food safety | these common foods are poisonous! Check your dining table quickly

The.Net webapi uses groupname to group controllers to render the swagger UI

华为超融合FusionCube解决方案笔记

How to view encrypted information in text form

Knowledge points of C language documents

PXE principle and configuration

PXE原理与配置

What is the Internet of things? The most comprehensive explanation of common IOT protocols
![[map] universal map usage & two ways of fuzzy query](/img/ec/e95e4057af2b9133786bb4103d2daa.png)
[map] universal map usage & two ways of fuzzy query

1-6月中国ADAS供应商占比9% 又一家零部件巨头全面布局智驾新赛道
随机推荐
Flink is slow to write redis. Do you have any ideas for optimization?
After being fined "paid leave" for one month, Google fired him who "loves" AI
如何组装一个注册中心?
Industry case | how does the index help the sustainable development of Inclusive Finance in the banking industry
PXE principle and configuration
Code error reporting and problem solving experience II: test error reporting in yolov5
Huawei ultra fusion fusioncube solution notes
Remote IP debugger (Practical dry goods)
QT introduction and case explanation
STM32 drives hc05 Bluetooth serial port communication module
回溯——第51题. N皇后——必须攻克的经典回溯难题
Minesweeping games - easy to play addictive (C language version)
Emerging security providers to learn about in 2022
Does anyone know where the retract of flinksql can be specified? Only api code settings can be seen in online materials
The best engineer was "forced" away by you like this!
The.Net webapi uses groupname to group controllers to render the swagger UI
MySQL可以自定义变参存储函数吗?
Kubernetes ---- life cycle introduction of PV and PVC
Kubernetes -- Introduction to common plug-ins of kubernetes
Detailed interpretation of hole convolution (input and output size analysis)