May 18, 2021 WeChat Mini Program Development Document
1. 1. Under the same type of equipment, the dimensions are nuanced
2. 2. When the screen is allowed to rotate, it can be divided into horizontal and vertical screens
3. 3. Different types of devices or PC programs that can drag windows freely
At present, the user devices on the market can be roughly divided into small screen mobile phone end, medium screen tablet, large screen PC side three categories, and in these three types of devices will have small size differences, also known as screen fragmentation.
As small programs can run on more and more device terminals, developers should also adapt to different screen sizes.
In accordance with the general principle of fit, combined with the characteristics of small procedures, it is usually necessary to adapt in three cases:
Using the rpx units provided by the small program, the page layout is scaled equally with little difference in size.
The phone settings "pageOrientation": "auto" or "resizable" on the iPad: true allows the screen to rotate, and the onResize event or wx.onWindowResize method of Page allows you to monitor the operation to determine whether you are using a horizontal or vertical layout.
The widget is currently webview-based, using CSS media queries to monitor screen sizes in real time, presenting different UI layouts under different screens, and combining Flex elastic layouts with Grid grid layouts enables more responsive fit scenarios.
Matchmedia - abstract media query
小程序基础库基于 window.matchMedia API 新增了一组过程式与定义式接口 match-media 。开发者可以通过 <match-media></match-media> 和 wx.createMediaQueryObserver 来显式地使用媒体查询能力,对于多端适配来说,它有以下优势:
In order to make developers better adaptive large screens, the applet provides the ROW / COL component for developers.
The main feature of adaptive is:
Design guidelines and code examples
About how to achieve better multi-end adaptation applets in design and user experience.
At the same time, we also provide a multi-end adaptation example applet, and a common adaptive scenario is simply implemented based on the ROW / COL component, for example:
Experience path: "Extension capabilities" -> "multi-end adaptation (need to experience in PC)"