In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
In this article "how to obtain system information in WeChat Mini Programs", the sample code in the article is introduced in great detail and has a certain reference value. Friends who are interested must refer to "how to obtain system information in WeChat Mini Programs". The editor sorted out the following knowledge points, please follow the pace of the editor to understand step by step, and then let's get into the topic.
Wx.getSystemInfo (OBJECT)
Get system information.
OBJECT parameter description:
The parameter type is required to indicate that successFunction is the callback function of successful API call failFunction No API call failed callback function completeFunction No callback function at the end of API call (both successful and failed calls will be executed)
Success callback parameter description:
Parameter description minimum version model mobile phone model pixelRatio device pixel ratio screenWidth screen width 1.1.0screenHeight screen height 1.1.0windowWidth available window width windowHeight available window height language Wechat set language version Wechat version number system operating system version platform client platform fontSizeSetting user font size setting. Subject to the settings in "I-Settings-General-Font size", unit: px1.5.0SDKVersion client Base Library version 1.1.0
Sample code:
Wx.getSystemInfo ({success: function (res) {console.log (res.model) console.log (res.pixelRatio) console.log (res.windowWidth) console.log (res.windowHeight) console.log (res.language) console.log (res.version) console.log (res.platform)
})
Wx.getSystemInfoSync ()
Get system information synchronization interface
Description of synchronous return parameters:
Parameter description minimum version model mobile phone model pixelRatio device pixel ratio screenWidth screen width 1.1.0screenHeight screen height 1.1.0windowWidth available window width windowHeight available window height language Wechat set language version Wechat version number system operating system version platform client platform SDKVersion client base library version 1.1.0
Sample code:
Try {var res = wx.getSystemInfoSync () console.log (res.model) console.log (res.pixelRatio) console.log (res.windowWidth) console.log (res.windowHeight) console.log (res.language) console.log (res.version) console.log (res.platform) catch (e) {/ / Do something when catch error} wx.canIUse (String)
Determine whether the API, callbacks, parameters, components, etc. of Mini Program are available in the current version.
String parameter description: use ${API}. ${method}. ${param}. ${options} or ${component}. ${attribute}. ${option}, for example:
${API} stands for API name
${method} represents the calling method. Valid values are return, success, object, callback.
${param} represents a parameter or a return value
${options} represents the optional value of the parameter
${component} represents the component name
${attribute} represents component properties
${option} represents the optional value of the component property
Example:
Wx.canIUse ('openBluetoothAdapter') wx.canIUse (' getSystemInfoSync.return.screenWidth') wx.canIUse ('getSystemInfo.success.screenWidth') wx.canIUse (' showToast.object.image') wx.canIUse ('onCompassChange.callback.direction') wx.canIUse (' request.object.method.GET') wx.canIUse ('contact-button') wx.canIUse (' text.selectable') wx.canIUse ('button.open-type.contact') what is the advantage of Mini Program compared to developers, it is less difficult to develop Can save development and operating costs, so that developers can quickly develop a Mini Program. And Mini Program can be easily obtained and spread in Wechat, which can meet the basic life applications, in line with life services offline stores and non-rigid needs of low-frequency applications. For users, it can save time cost and mobile phone memory space, and have excellent use experience at the same time.
The above is all the contents of the article "how to get system Information in WeChat Mini Programs". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.