API

Framework provides many WeChat native APIs that can be conveniently called to access abilities provided by WeChat, such as acquiring user information, local storage, payment functions etc.

Instruction:

  • APIs that start with wx.on are API interfaces for monitoring certain events. They accept a CALLBACK function as a parameter. When the event is triggered, the CALLBACK function is called.
  • If there are no special arrangements, other API interfaces all accept an OBJECT as a parameter.
  • Within the OBJECT you can specify success, fail, complete to accept the interface call result.
Parameter Name Type Required Description
success Function No Callback function when interface call succeeded
fail Function No Callback function when interface call failed
complete Function No Callback function when interface call completed (always executed whether call succeeds or fails)

API list:

Network API list:

API Description
wx.request Send network request
wx.uploadFile Upload file
wx.downloadFile Download file
wx.connectSocket Create WebSocket link
wx.onSocketOpen Monitor WebSocket opening
wx.onSocketError Monitor WebSocket errors
wx.sendSocketMessage Send WebSocket messages
wx.onSocketMessage Receive WebSocket messages
wx.closeSocket Close WebSocket connection
wx.onSocketClose Monitor WebSocket closing

Media API list:

API Description
wx.chooseImage Select an image from an album, or take a picture
wx.previewImage Preview image
wx.startRecord Start recording
wx.stopRecord End recording
wx.playVoice Play voice message
wx.pauseVoice Pause voice message
wx.stopVoice Stop voice message
wx.getBackgroundAudioPlayerState Acquire music playing status
wx.playBackgroundAudio Play music
wx.pauseBackgroundAudio Pause music
wx.seekBackgroundAudio Control the music playback progress
wx.stopBackgroundAudio Stop music
wx.onBackgroundAudioPlay Monitor music playing
wx.onBackgroundAudioPause Monitor music pausing
wx.onBackgroundAudioStop Monitor music stopping
wx.chooseVideo Select a video from an album, or record a video
wx.loadFontFace Dynamic loading font

File API list:

API Description
wx.saveFile Save File
wx.getSavedFileList Acquire saved file list
wx.getSavedFileInfo Acquire saved file information
wx.removeSavedFile Delete saved file information
wx.openDocument Open File

Data API list:

API Description
wx.getStorage Acquire local data cache
wx.getStorageSync Acquire local data cache
wx.setStorage Set local data cache
wx.setStorageSync Set local data cache
wx.getStorageInfo Acquire local cache related information
wx.getStorageInfoSync Acquire local cache related information
wx.removeStorage Delete local cache
wx.removeStorageSync Delete local cache
wx.clearStorage Clear local data cache
wx.clearStorageSync Clear local data cache

Location API list:

API Description
wx.getLocation Acquire current location
wx.chooseLocation Open the map and select a location
wx.openLocation Open the built-in map
wx.createMapContext Map component control

Device API list:

API Description
wx.getNetworkType Acquire network type
wx.onNetworkStatusChange Monitor network status changes
wx.getSystemInfo Acquire system information
wx.getSystemInfoSync Acquire system information
wx.onAccelerometerChange Monitor acceleration data
wx.startAccelerometer Start monitoring acceleration data
wx.stopAccelerometer Stop monitoring acceleration data
wx.onCompassChange Monitor compass data
wx.startCompass Start monitoring compass data
wx.stopCompass Stop monitoring compass data
wx.setClipboardData Set clipboard data
wx.getClipboardData Acquire clipboard data
wx.makePhoneCall Make a phone call
wx.scanCode Scan a code

Interface API list:

API Description
wx.showToast Show prompt
wx.showLoading Show loading prompt
wx.hideToast Hide prompt
wx.hideLoading Hide prompt
wx.showModal Display modal pop-up window
wx.showActionSheet Display menu list
wx.setNavigationBarTitle Set title of current page
wx.showNavigationBarLoading Display the navigation bar loading animation
wx.hideNavigationBarLoading Hide the navigation bar loading animation
wx.setBackgroundColor Dynamically set window background color
wx.setBackgroundTextStyle Dynamically set font and "loading" image style of pull-down background
wx.navigateTo Open the page in a new window
wx.redirectTo Open the page in the original window
wx.switchTab Switch to the "tabbar" page
wx.navigateBack Go back to the previous page
wx.createAnimation Animation
wx.createContext Create drawing context
wx.drawCanvas Draw
wx.stopPullDownRefresh Stop the pull-down refresh animation

WXML node information API list

API Description
wx.createSelectorQuery Create query request
selectorQuery.in Specify from which custom component to select a node
selectorQuery.select Select a single node based on the selector
selectorQuery.selectAll Select all nodes based on the selector
selectorQuery.selectViewport Select display area
nodesRef.boundingClientRect Acquire layout position and dimensions
nodesRef.scrollOffset Acquire scroll position
nodesRef.fields Acquire any field
selectorQuery.exec Execute query request

WXML node layout intersection status

API Description
wx.createIntersectionObserver Create IntersectionObserver object
intersectionObserver.relativeTo Specify parameter node
intersectionObserver.relativeToViewport Specify page display area as reference area
intersectionObserver.observe Specify target node and start monitoring
intersectionObserver.disconnect Stop monitoring

Open interface:

API Description
wx.login Log in
wx.getUserInfo Get user information
wx.chooseAddress Get user delivery address
wx.requestPayment Initiate WeChat payment
wx.addCard Add card/voucher
wx.openCard Open card/voucher

个结果 ""

    没有找到相关内容 ""