当前位置:网站首页>Vant realizes the adaptation of mobile terminal
Vant realizes the adaptation of mobile terminal
2022-06-13 02:41:00 【Zixuan Pavilion】
Recently, the company did a mobile terminal project , Need to fit , The framework itself provides vue-cli3.0 combination lib-flexible and px2rem A scheme to realize mobile terminal adaptation , Here is a record of how you do the adaptation .
Introduce postcss-pxtorem Is a postcss plug-in unit , Used to convert units to rem amfe-flexible Used for setting up rem
At baseline
- install amfe-flexible
1. npm i -S amfe-flexible
- stay main.js Introduce in the file lib-flexible
import 'amfe-flexible/index.js'
- install postcss-pxtorem
npm install postcss-pxtorem --save-dev
4. stay public/index.html Join in meta label
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
5. Project configuration postcss
stay package.json Add such a piece of code
"postcss": {
"plugins": {
"autoprefixer": {
"overrideBrowserslist": [
"Android 4.1",
"iOS 7.1",
"Chrome > 31",
"ff > 31",
"ie >= 8"
]
},
"postcss-pxtorem": {
"rootValue": 37.5,
"propList": [
"*"
]
}
}
}
This completes the adaptation , It should be noted that ,css Inside we just need to write px, Then it will be automatically converted to rem Show in browser ,rootValue Set to 37.5, The reason why it is set to 37.5, To quote something like vant Such a third party UI frame , Because the third-party framework is not compatible rem, It's using px Company , take rootValue The value of is set to the width of the design drawing ( Here for 750px)75 Half of , That is to say 1:1 Restore vant、mint-ui The components of , Otherwise, the style will change , For example, the button will become smaller . Now that it's set to 37.5 Then we must write the style , Also change the value to half of the design drawing .
边栏推荐
- Hstack, vstack and dstack in numpy
- Image classification system based on support vector machine (Matlab GUI interface version)
- Sans certificate generation
- 如何挑选基金产品?什么样的基金是好基金?
- Termux SSH first shell start
- [deep learning] fast Reid tutorial
- [reading papers] comparison of deeplobv1-v3 series, brief review
- A real-time target detection model Yolo
- [reading papers] deep learning face representation by joint identification verification, deep learning applied to optimization problems, deepid2
- too old resource version,Code:410
猜你喜欢
冲刺强基计划数学物理专题一
An image is word 16x16 words: transformers for image recognition at scale
Queuing theory, game theory, analytic hierarchy process
03 认识第一个view组件
[data and Analysis Visualization] D3 introductory tutorial 2- building shapes in D3
Uni app Foundation
Data processing in detailed machine learning (II) -- Feature Normalization
03 recognize the first view component
Summary of innovative ideas of transformer model in CV
Leetcode 473. 火柴拼正方形 [暴力+剪枝]
随机推荐
Microsoft Pinyin opens U / V input mode
[data analysis and visualization] key points of data drawing 9- color selection
Thinking back from the eight queens' question
[data analysis and visualization] key points of data drawing 3- spaghetti map
Rounding in JS
03 recognize the first view component
Matlab: obtain the figure edge contour and divide the figure n equally
在IDEA使用C3P0连接池连接SQL数据库后却不能显示数据库内容
Node uses post to request req Pit with empty body
Opencv 17 face recognition
遍历数组,删除某元素,直到删除为止
Surpass the strongest variant of RESNET! Google proposes a new convolution + attention network: coatnet, with an accuracy of 89.77%!
Paper reading - group normalization
Leetcode 926. Flip string to monotonically increasing [prefix and]
How to destroy a fragment- How to destroy Fragment?
House raiding
03 认识第一个view组件
[reading papers] dcgan, the combination of generating countermeasure network and deep convolution
regular expression
Queuing theory, game theory, analytic hierarchy process