简单记录第一个原生小程序遇到的问题
1. userinfo : -41003
//授权
onTapLogin: function (res) {
const that = this;
that.setData({
loading: true
});
wx.showToast({
title: '正在加载...',
icon: 'loading',
duration: 40000,
});
if (res.detail.errMsg === 'getUserInfo:ok') {
console.log(res);
wx.login({
success(result) {
if (result.code) {
// 为了解决 userinfo : -41003
wx.getUserInfo({
success(response) {
// 走后台验证接口
}
});
} else {
}
}
})
} else {
}
}
2.关于wx.canvasToTempFilePath(Object object, Object this)这个api,报错 canvasToTempFilePath: fail canvas is empty
把当前画布指定区域的内容导出生成指定大小的图片,在自定义组件下,当前组件实例的this,以操作组件内 组件。
const that = this;
wx.canvasToTempFilePath({
canvasId: 'canvasGrowth',
quality: 1,
success(res) {
},
fail(err) {
}
}, that.selectComponent('#mychart-dom-bar'))
that.selectComponent('#mychart-dom-bar')就是这个组件的实例, mychart-dom-bar是组件的id;