微信小程序开发常用的API 有哪些 案例 代码示例
1.
1. 1、获取用户信息
1.
1. 代码示例:
1.
1. //获取用户信息
1. wx.getUserInfo({
1. success:function(res){
1. console.log(res)
1. }
1. })
1.
1. 2、获取系统信息
1.
1. 代码示例:
1.
1. //获取系统信息
1. wx.getSystemInfo({
1. success:function(res){
1. console.log(res)
1. }
1. })
1.
1. 3、页面跳转
1.
1. 代码示例:
1.
1. //页面跳转
1. wx.navigateTo({
1. url: '/pages/index/index'
1. })
1.
1. 4、获取网络状态
1.
1. 代码示例:
1.
1. //获取网络状态
1. wx.getNetworkType({
1. success:function(res){
1. console.log(res)
1. }
1. })
1.
1. 5、发起请求
1.
1. 代码示例:
1.
1. //发起请求
1. wx.request({
1. url: 'https://www.example.com',
1. success:function(res){
1. console.log(res)
1. }
1. })