May 18, 2021 WeChat Mini Program Development Document
Base library 1.6.4 starts to support, and low versions need to be compatible
The web-view component is a container that can be used to host Web pages and automatically fills the entire web page. Small programs of personal type and overseas type are not supported for the time being.
The property name | Type | The default | Description |
---|---|---|---|
Src | String | none | Webview's link to a Web page. You need to log in to the small program management background configuration domain name whitelist. |
Example code:
<!-- wxml -->
<!-- 指向微信公众平台首页的web-view -->
<web-view src="https://mp.weixin.qq.com/" rel="external nofollow" ></web-view>
The interface provided by JSSDK 1.3.0 can be used to return to the program page. The supported interfaces are:
The name of the interface | Description | The lowest version |
---|---|---|
wx.miniProgram.navigateTo | The parameters are consistent with the small program interface | 1.6.4 |
wx.miniProgram.navigateBack | The parameters are consistent with the small program interface | 1.6.4 |
wx.miniProgram.switchTab | The parameters are consistent with the small program interface | 1.6.5 |
wx.miniProgram.reLaunch | The parameters are consistent with the small program interface | 1.6.5 |
wx.miniProgram.redirectTo | The parameters are consistent with the small program interface | 1.6.5 |
Example code:
<!-- html -->
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.3.0.js" rel="external nofollow" ></script>
// javascript
wx.miniProgram.navigateTo({url: '/path/to/page'})
Only the following JSSDK interfaces are supported on the web page:
Interface module | The interface description | The specific interface |
---|---|---|
Determines whether the client supports js | checkJSApi | |
The image interface | Take a photo or upload it | chooseImage |
Preview the picture | previewImage | |
Upload an image | uploadImage | |
Download the picture | downloadImage | |
Get a local picture | getLocalImgData | |
The audio interface | Start recording | startRecord |
Stop recording | stopRecord | |
Listening to the recording stops automatically | onVoiceRecordEnd | |
Play voice | playVoice | |
Pause playback | pauseVoice | |
Stop play | stopVoice | |
Listening to speech | onVoicePlayEnd | |
Upload interface | uploadVoice | |
Download interface | downloadVoice | |
Intelligent interface | Identify audio | translateVoice |
Device Information | Get a network status | getNetworkType |
Geographic location | Use built-in map | getLocation |
Get a geographic location | openLocation | |
Shake around the surrounding | Open Ibeacon | startSearchBeacons |
Close Ibeacon | stopSearchBeacons | |
Monitor iBeacon | onSearchBeacons | |
WeChat sweep | Tun up WeChat sweep | scanQRCode |
WeChat voucher | Pull the list of vouchers used | chooseCard |
Add the voucher interface in bulk | addCard | |
Check the voucher for the WeChat card bag | openCard | |
Press and hold to identify | Small program round code | No |
When the user shares, they can get the URL of the current slt;web-view/sgt; that is, return the webViewUrl parameter in the onShareAppMessage callback.
Example code:
Page({
onShareAppMessage(options) {
console.log(options.webViewUrl)
}
})
Within a Web page, you can window.__wxjs_environment a small program environment by using a few variables.
Example code:
// web-view下的页面内
wx.ready(function() {
console.log(window.__wxjs_environment === 'miniprogram') // true
})