In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to use Mini Program's development document web-view". In daily operation, I believe many people have doubts about how to use Mini Program's development document web-view. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "how to use Mini Program's development document web-view!" Next, please follow the editor to study!
The use of web-view
You should specify a specific path to open any page in the whitelist of the business domain name. Page directory
Since the page only renders the web page, and no other components are displayed, only one such component can be included in the corresponding HTML:
The main logic of web-view/index.js is as follows:
Page ({data: {url:',}, onLoad () {const sysInfo = wx.getSystemInfoSync (); const version = new Version (sysInfo.SDKVersion)) / / the web-view component is supported by 1.6.4 basic library / / but its JS-SDK has not been supported since 1.6.6 / so the minimum requirement here is 1.6.6 if (version.isLowerThan ('1.6.6')) {return wx.showModal ({title: 'hint', content: 'the current Wechat version is too low Unable to open the web page in Mini Program, please upgrade to the latest Wechat version and try again.' , showCancel: false, confirmText: 'got it', success () {wx.navigateBack ();}});} / / you can get the query parameter if (options & & options.__host) {let url = decodeURIComponent (options.__host |') in URL; const query = Object.assign ({}, options); delete query.__host Url + ='? + util.stringifyQuery (query); this.setData ({url});}})
Other pages can do this when they want to use web-view, way 1:
Open a web page through web-view
Or method 2:
Const url = 'https://your.host.name/path/to/page?query_1=value_1&query_2=value_2';wx.navigateTo({ url:' / pages/webview/index__host=' + encodeURIComponent (url)}); data cache
You can make full use of Mini Program's storage interface for local caching. Recommended cached data include:
Metadata the basic data of a user after login, such as userId,token device ID picture resources
Because the relative path can not be used in Mini Program's stylesheet to reference picture files, so most of the time we have to use base64 for transcoding.
Commonly used classes are used for request.js of network requests, supporting Promise interface version judgment, Version.js time and date formatting, similar to moment.js, but more lightweight URL parsing and serialization, url.js compatibility
Under iOS and Android platforms, even if the same Mini Program, there are many differences in details. When conducting compatibility testing, you need to test according to the platform compatibility of H5.
In addition, there are compatibility tests for various versions of Wechat. The front end should judge WeChat Mini Programs SDKVersion based on Version.js in order to give a friendly hint to the lower version.
At this point, on the "Mini Program development documentation how to use web-view" study is over, I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.