微信小程序 使用云函数 获取accessToken
·
一、小程序端(客户端某页面.js)

// 获取access token
wx.cloud.callFunction({
// 云函数名称
name: 'getAccessToken',
// 传给云函数的参数
data: {},
})
.then(res => {
this.setData({
accessToken: JSON.parse(res.result).access_token
});
// console.log('云函数获取accesstoken:', this.data.accessToken);
})
.catch(console.error)
二、云函数
注意got的版本如果是10.x就不行


=============
若使用云函数
需要:
1.app.json

2.project.config.json

3.app.js

更多推荐
所有评论(0)