2020.11.27都没有解决吗 延迟2秒都没有执行
wx.canvastotempfilepath 为什么不执行?则个是测试随便写的。wx.canvastotempfilepath 中的三个回调都没有执行。 [代码]//index.js[代码][代码]//获取应用实例[代码][代码]const app = getApp()[代码] [代码]Page({[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]motto: [代码][代码]'Hello World'[代码][代码],[代码][代码] [代码][代码]userInfo: {},[代码][代码] [代码][代码]hasUserInfo: [代码][代码]false[代码][代码],[代码][代码] [代码][代码]canIUse: wx.canIUse([代码][代码]'button.open-type.getUserInfo'[代码][代码])[代码][代码] [代码][代码]},[代码][代码] [代码][代码]//事件处理函数[代码][代码] [代码][代码]bindViewTap: [代码][代码]function[代码][代码]() {[代码][代码] [代码][代码]wx.navigateTo({[代码][代码] [代码][代码]url: [代码][代码]'../logs/logs'[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]onLoad: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]if[代码] [代码](app.globalData.userInfo) {[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]userInfo: app.globalData.userInfo,[代码][代码] [代码][代码]hasUserInfo: [代码][代码]true[代码][代码] [代码][代码]})[代码][代码] [代码][代码]} [代码][代码]else[代码] [代码]if[代码] [代码]([代码][代码]this[代码][代码].data.canIUse){[代码][代码] [代码][代码]// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回[代码][代码] [代码][代码]// 所以此处加入 callback 以防止这种情况[代码][代码] [代码][代码]app.userInfoReadyCallback = res => {[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]userInfo: res.userInfo,[代码][代码] [代码][代码]hasUserInfo: [代码][代码]true[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]} [代码][代码]else[代码] [代码]{[代码][代码] [代码][代码]// 在没有 open-type=getUserInfo 版本的兼容处理[代码][代码] [代码][代码]wx.getUserInfo({[代码][代码] [代码][代码]success: res => {[代码][代码] [代码][代码]app.globalData.userInfo = res.userInfo[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]userInfo: res.userInfo,[代码][代码] [代码][代码]hasUserInfo: [代码][代码]true[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]},[代码][代码] [代码][代码]getUserInfo: [代码][代码]function[代码][代码](e) {[代码][代码] [代码][代码]console.log(e)[代码][代码] [代码][代码]app.globalData.userInfo = e.detail.userInfo[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]userInfo: e.detail.userInfo,[代码][代码] [代码][代码]hasUserInfo: [代码][代码]true[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]onShow () {[代码][代码] [代码][代码]console.log(123)[代码][代码] [代码][代码]wx.canvasToTempFilePath({[代码][代码] [代码][代码]canvasId: [代码][代码]'myCanvas'[代码][代码],[代码][代码] [代码][代码]success(res) {[代码][代码] [代码][代码]console.log([代码][代码]"success"[代码][代码])[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail () {[代码][代码] [代码][代码]console.log([代码][代码]"fali"[代码][代码])[代码][代码] [代码][代码]},[代码][代码] [代码][代码]complete () {[代码][代码] [代码][代码]console.log([代码][代码]"complete"[代码][代码])[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码]})[代码]
2020-11-27