怎么解决?哪位大神有办法解决?
app.js存储的数据 index.js获取不到的问题app.js 在 onLaunch 里面存储在 globalData 和 storage的数据 在index.js里面的 onLoad 会有一定几率获取不到.
2018-09-26怎么解决?解决这个问题了吗
app对象中的globalData存储和获取值不一致- 当前 Bug 的表现(可附上截图) [代码]console.log(that.globalData.openid);[代码][代码]console.log(that.globalData.hasUserInfo);[代码][代码]console.log(that.globalData);[代码][图片] - 预期表现 openid应当有值 - 复现路径 app.js直接执行 - 提供一个最简复现 Demo [代码]//app.js[代码][代码]App({[代码][代码] [代码][代码]onLaunch: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]},[代码][代码] [代码][代码]globalData: {[代码][代码] [代码][代码]userInfo: [代码][代码]null[代码][代码],[代码][代码] [代码][代码]openid:[代码][代码]null[代码][代码],[代码][代码] [代码][代码]hasUserInfo: [代码][代码]false[代码][代码],[代码][代码] [代码][代码]apiUrl: [代码][代码]'https://www.baidu.com'[代码][代码],[代码][代码] [代码][代码]},[代码][代码] [代码][代码]getUserInfo: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码];[代码] [代码] [代码][代码]if[代码] [代码](that.globalData.hasUserInfo == [代码][代码]false[代码][代码]) {[代码] [代码] [代码][代码]wx.login({[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]if[代码] [代码](res.code) {[代码][代码] [代码][代码]var[代码] [代码]code = res.code;[代码][代码] [代码][代码]wx.request({[代码][代码] [代码][代码]url: that.globalData.apiUrl,[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]'controller'[代码][代码]: [代码][代码]'Api\\Wuji\\Zhanguan'[代码][代码],[代码][代码] [代码][代码]'method'[代码][代码]: [代码][代码]'authorization'[代码][代码],[代码][代码] [代码][代码]'code'[代码][代码]:res.code[代码][代码] [代码][代码]},[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]that.globalData.openid = [代码][代码]'this is openid'[代码][代码];[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码][代码] [代码][代码]});[代码] [代码] [代码][代码]wx.getUserInfo({[代码][代码] [代码][代码]success: res => {[代码][代码] [代码][代码]//save infomation[代码][代码] [代码][代码]that.globalData.userInfo = res.userInfo;[代码][代码] [代码][代码]that.globalData.hasUserInfo = [代码][代码]true[代码][代码];[代码][代码] [代码][代码]that.saveUserInfo();[代码][代码] [代码][代码]},[代码][代码] [代码][代码]fail: res => {[代码][代码] [代码][代码]wx.openSetting({[代码][代码] [代码][代码]success: (res) => {[代码][代码] [代码][代码]if[代码] [代码](res.authSetting[[代码][代码]"scope.userInfo"[代码][代码]] == [代码][代码]false[代码][代码]) {[代码][代码] [代码][代码]wx.showToast({[代码][代码] [代码][代码]title: [代码][代码]'用户未登录'[代码][代码],[代码][代码] [代码][代码]icon: [代码][代码]'none'[代码][代码],[代码][代码] [代码][代码]duration: [代码][代码]2000[代码][代码] [代码][代码]});[代码][代码] [代码][代码]}[代码][代码]else[代码][代码]{[代码][代码] [代码][代码]wx.getUserInfo({[代码][代码] [代码][代码]success: res => {[代码][代码] [代码][代码]//save infomation[代码][代码] [代码][代码]that.globalData.userInfo = res.userInfo;[代码][代码] [代码][代码]that.globalData.hasUserInfo = [代码][代码]true[代码][代码];[代码][代码] [代码][代码]that.saveUserInfo();[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]});[代码][代码] [代码][代码]}[代码][代码] [代码][代码]},[代码][代码] [代码][代码]saveUserInfo:[代码][代码]function[代码][代码](){[代码][代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码];[代码] [代码] [代码][代码]console.log(that.globalData.openid);[代码][代码] [代码][代码]console.log(that.globalData.hasUserInfo);[代码][代码] [代码][代码]console.log(that.globalData);[代码] [代码] [代码][代码]if[代码] [代码](that.globalData.openid != [代码][代码]null[代码] [代码]&& that.globalData.hasUserInfo == [代码][代码]true[代码][代码]){[代码] [代码] [代码][代码]wx.request({[代码][代码] [代码][代码]url: that.globalData.apiUrl,[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]'controller'[代码][代码]: [代码][代码]'Api\\Wuji\\Zhanguan'[代码][代码],[代码][代码] [代码][代码]'method'[代码][代码]: [代码][代码]'saveUserInfo'[代码][代码],[代码][代码] [代码][代码]'openid'[代码][代码]: that.globalData.openid,[代码][代码] [代码][代码]'nickname'[代码][代码]: that.globalData.userInfo.nickName,[代码][代码] [代码][代码]'avatar'[代码][代码]: that.globalData.userInfo.avatarUrl,[代码][代码] [代码][代码]'gender'[代码][代码]: that.globalData.userInfo.gender,[代码][代码] [代码][代码]'province'[代码][代码]: that.globalData.userInfo.province,[代码][代码] [代码][代码]'city'[代码][代码]: that.globalData.userInfo.city[代码][代码] [代码][代码]},[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log(res);[代码][代码] [代码][代码]if[代码] [代码](res.data.status == [代码][代码]200[代码][代码]) {[代码][代码] [代码][代码]var[代码] [代码]data = res.data.data;[代码][代码] [代码][代码]//console.log(data);[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码][代码] [代码][代码]});[代码][代码] [代码][代码]}[代码] [代码] [代码][代码]},[代码][代码] [代码][代码]cutString: [代码][代码]function[代码] [代码](str, len, fill = [代码][代码]'...'[代码][代码]) {[代码][代码] [代码][代码]if[代码] [代码](str.length * [代码][代码]2[代码] [代码]<= len) {[代码] [代码] [代码][代码]return[代码] [代码]str;[代码] [代码] [代码][代码]}[代码][代码] [代码][代码]var[代码] [代码]strlen = [代码][代码]0[代码][代码];[代码][代码] [代码][代码]var[代码] [代码]s = [代码][代码]""[代码][代码];[代码][代码] [代码][代码]for[代码] [代码]([代码][代码]var[代码] [代码]i = [代码][代码]0[代码][代码]; i < str.length; i++) {[代码][代码] [代码][代码]s = s + str.charAt(i);[代码][代码] [代码][代码]if[代码] [代码](str.charCodeAt(i) > [代码][代码]128[代码][代码]) {[代码][代码] [代码][代码]strlen = strlen + [代码][代码]2[代码][代码];[代码][代码] [代码][代码]if[代码] [代码](strlen >= len) {[代码][代码] [代码][代码]return[代码] [代码]s.substring([代码][代码]0[代码][代码], s.length - [代码][代码]1[代码][代码]) + fill;[代码][代码] [代码][代码]}[代码][代码] [代码][代码]} [代码][代码]else[代码] [代码]{[代码][代码] [代码][代码]strlen = strlen + [代码][代码]1[代码][代码];[代码][代码] [代码][代码]if[代码] [代码](strlen >= len) {[代码][代码] [代码][代码]return[代码] [代码]s.substring([代码][代码]0[代码][代码], s.length - [代码][代码]2[代码][代码]) + fill;[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码][代码] [代码][代码]return[代码] [代码]s;[代码][代码] [代码][代码]}[代码][代码]})[代码]
2018-09-26遇到同样的问题了
小程序内嵌网页,input position:fixed键盘挡住输入框- 当前 Bug 的表现(可附上截图) 弹出键盘,挡住input输入框 [图片] [图片] - 预期表现 弹出键盘,input跟随键盘上面 - 复现路径 1、安卓手机 2、<div style="position: fixed;bottom:0;left:0;right:0"><input type="password" /></div> 3、input获取焦点,弹出键盘,input输入框被挡住 - 提供一个最简复现 Demo <div style="position:fixed;left:0;right:0;bottom:0;background-color:#f00;padding:2px;"> <input type="password" style="padding:5px 0;width:100%;" /> </div> 小程序可以用原生的cursor-spacing解决,但是内嵌的网页如何解决那?
2018-09-04