当前位置:网站首页>【微信小程序】Chapter(5):微信小程序基础API接口
【微信小程序】Chapter(5):微信小程序基础API接口
2022-07-07 13:26:00 【wangzirui32】
博文作者 wangzirui32
喜欢的可以 点赞 收藏 关注哦~~
本文首发于CSDN,未经许可禁止转载hello,大家好,我是wangzirui32,今天我们来学习微信小程序基础API接口,开始学习吧!
目录
1. wx.request
功能:请求服务器的数据,仅支持发起 HTTPS 网络请求。
参数:
示例:
wx.request({
url: 'https://114.51.4.191',
data: {
"a": "abc"
},
})
2. wx.downloadFile
功能:下载网络上的文件。
属性:
请求成功后的回调函数参数:
示例:
wx.downloadFile({
url: 'https://11.45.14.19/files/19810', // 示例资源地址
success (res) {
if (res.statusCode === 200) {
alert("OK");
};
}})
3.wx.uploadFile()
功能:上传文件到指定url。
属性
调用成功回调参数:
示例:
wx.uploadFile({
url: 'https://11.45.14.19/upload',
filePath: "example_filepath",
name: 'file',
formData: {
'date': '2022-7-5'
},
success (res){
var data = res.data;
}
})
4. wx.switchTab
功能:跳转到 TabBar 页面。
属性:
示例:
wx.switchTab({
url: '/example_1'
})
5. wx.reLaunch
功能:关闭所有页面,打开到应用内的某个页面。
属性:
示例:
wx.reLaunch({
url: '/example_2'
})
6. wx.redirectTo
功能:跳转到某个页面。
属性:
示例:
wx.redirectTo({
url: '/example_3'
})
7. wx.navigateTo
功能:保留当前页面,跳转到应用内的某个页面。
属性:
示例:
wx.navigateTo({
url: '/example_4'
})
8. wx.navigateBack
功能:关闭当前页面,返回上一页面。
属性:
示例:
wx.navigateBack({
url: '/example_5'
})
9. EventChannel
9.1 EventChannel.emit
功能:触发一个事件。
结构:
EventChannel.emit(事件名称)
9.2 EventChannel.off
功能:取消监听一个事件。
结构:
EventChannel.off(事件名称, 回调函数)
9.3 EventChannel.on
功能:持续监听一个事件。
结构:
EventChannel.on(事件名称, 回调函数)
9.4 EventChannel.once
功能:监听一个事件一次,触发后失效。
结构:
EventChannel.once(事件名称, 回调函数)
10. wx.canIUse
功能:判断小程序的API,回调,参数,组件等是否在当前版本可用。
返回值:布尔值(True或者False)。
结构:
wx.canIUse(schema)
// schema 参数格式(有2种)
// 1. ${API}.${method}.${param}.${option}
// 2. ${component}.${attribute}.${option}
好了,今天的课程就到这里,我是wangzirui32,喜欢的可以点个收藏和关注,我们下次再见!
边栏推荐
- Jacobo code coverage
- Oracle控制文件丢失恢复归档模式方法
- Unity's ASE realizes cartoon flame
- Pit avoidance: description of null values in in and not in SQL
- [data mining] visual pattern mining: hog feature + cosine similarity /k-means clustering
- What are the safest securities trading apps
- Steps to create P8 certificate and warehousing account
- [quick start of Digital IC Verification] 29. Ahb-sramc (9) (ahb-sramc svtb overview) of SystemVerilog project practice
- Basic knowledge sorting of mongodb database
- HW primary flow monitoring, what should we do
猜你喜欢
什麼是數據泄露
[server data recovery] a case of RAID data recovery of a brand StorageWorks server
Unity's ASE achieves full screen sand blowing effect
[data mining] visual pattern mining: hog feature + cosine similarity /k-means clustering
Getting started with webgl (2)
【服务器数据恢复】戴尔某型号服务器raid故障的数据恢复案例
Keil5 does not support online simulation of STM32 F0 series
【数字IC验证快速入门】18、SystemVerilog学习之基本语法5(并发线程...内含实践练习)
【服务器数据恢复】某品牌StorageWorks服务器raid数据恢复案例
[quick start of Digital IC Verification] 25. AHB sramc of SystemVerilog project practice (5) (AHB key review, key points refining)
随机推荐
Configure mongodb database in window environment
Ctfshow, information collection: web13
【数字IC验证快速入门】18、SystemVerilog学习之基本语法5(并发线程...内含实践练习)
Steps to create P8 certificate and warehousing account
What is Base64?
Do not use memset to clear floating-point numbers
【数字IC验证快速入门】20、SystemVerilog学习之基本语法7(覆盖率驱动...内含实践练习)
一个需求温习到的所有知识,h5的表单被键盘遮挡,事件代理,事件委托
2. Basic knowledge of golang
Getting started with webgl (2)
[server data recovery] data recovery case of raid failure of a Dell server
Actually changed from 408 to self proposition! 211 North China Electric Power University (Beijing)
Whether runnable can be interrupted
2.Golang基础知识
Using eating in cocos Creator
What are the safest securities trading apps
什麼是數據泄露
Stm32f103c8t6 PWM drive steering gear (sg90)
How to release NFT in batches in opensea (rinkeby test network)
有钱人买房就是不一样