API | Description |
wx.miniProgram.navigateTo | The parameters are the same as those of the corresponding mini program API |
wx.miniProgram.navigateBack | The parameters are the same as those of the corresponding mini program API |
wx.miniProgram.switchTab | The parameters are the same as those of the corresponding mini program API |
wx.miniProgram.reLaunch | The parameters are the same as those of the corresponding mini program API |
wx.miniProgram.redirectTo | The parameters are the same as those of the corresponding mini program API |
wx.miniProgram.postMessage | Sends a message to the mini program, triggering the component's message event in specific scenarios such as returning to a mini program page, terminating or sharing a component and copying links |
wx.miniProgram.getEnv | Gets the current environment information |
API Module | API description | Specific APIs |
Image APIs | Take a photo or upload an image | chooseImage |
| Preview an image | previewImage |
| Upload an image | uploadImage |
| Download an image | downloadImage |
| Get local images | getLocalImgData |
Audio APIs | Start recording
| startRecord |
| Stop recording
| stopRecord |
| Recording listening stops automatically | onVoiceRecordEnd |
| Play audio | playVoice |
| Pause | pauseVoice |
| Stop playback | stopVoice |
| Audio playback listening ends | onVoicePlayEnd |
Device information | Get network status | getNetworkType |
Geographical location | Display location in built-in map | openLocation |
| Gets the geographical location | getLocation |
<!-- html --><script type="text/javascript" src="https://raw.githubusercontent.com/TencentCloud/tcmpp-demo-miniprogram/main/index.js"></script>
wx.miniProgram.navigateTo({url: '/path/to/page'})wx.miniProgram.postMessage({ data: 'foo' })wx.miniProgram.postMessage({ data: {foo: 'bar'} })wx.miniProgram.getEnv(function(res) { console.log(res.miniprogram) })
Page({onShareAppMessage(options) {console.log(options.webViewUrl)}})
// Inside the WebView pagefunction ready() {console.log(window.__wxjs_environment === 'miniprogram') // true}if (!window.WeixinJSBridge || !WeixinJSBridge.invoke) {document.addEventListener('WeixinJSBridgeReady', ready, false)} else {ready()}// Owx.miniProgram.getEnv(function(res) {console.log(res.miniprogram) // true})
Was this page helpful?