html52.com
我爱小程序-开发者交流社区

在onLoad(options)中,如下错误,求解

thirdScriptError

Cannot read property 'inviteCode' of undefined;at pages/index/index page lifeCycleMethod onLoad function

TypeError: Cannot read property 'inviteCode' of undefined

    at t.onLoad (http://127.0.0.1:61317/appservice/pages/index/index.js:682:18)

    at t.<anonymous> (http://127.0.0.1:61317/appservice/__dev__/WAService.js:18:21400)

    at t.onShow (http://127.0.0.1:61317/appservice/pages/index/index.js:901:10)

    at t.<anonymous> (http://127.0.0.1:61317/appservice/__dev__/WAService.js:18:21400)

    at Kt (http://127.0.0.1:61317/appservice/__dev__/WAService.js:19:5408)

    at en (http://127.0.0.1:61317/appservice/__dev__/WAService.js:19:7211)

    at nn (http://127.0.0.1:61317/appservice/__dev__/WAService.js:19:7549)

    at Function.<anonymous> (http://127.0.0.1:61317/appservice/__dev__/WAService.js:19:9990)

    at X.<anonymous> (http://127.0.0.1:61317/appservice/__dev__/WAService.js:18:9835)

    at X.emit (http://127.0.0.1:61317/appservice/__dev__/WAService.js:7:31757)




报错代码为:

onLoad: function (options) {

var page = this;

//分享获取参数“邀请码”,存为全局变量

// console.log(app.globalData.inviteCode +"-1-1号")

// console.log(options.inviteCode +"-1-2号")

if (app.globalData.inviteCode == '' || app.globalData.inviteCode==undefined){

// console.log(options.inviteCode +"-1-3号")

if (options.inviteCode != '' && options.inviteCode != undefined) {   //读到这一行就报错

app.globalData.inviteCode = options.inviteCode;

}

console.log(app.globalData.inviteCode +"-1-4号")

}

},


网友回复

꧁༺༽༾ཊ@_@ཏ༿༼༻꧂:

optionsapp.globalData有一个为undefined,看下你的app.js?还有你的onShow?

可乐:

我在跳转到当前页面前,是传了参数的,有没有办法屏蔽这种错误

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付