收藏
回答

TypeError: this.runscan is not a function?出现此问题

这段代码在page里,是部分代码,在该段后面(已用大粗字体标注),需要重新调用该函数,就提示下面两行,不知道为什么,请各位指正,谢谢。

this.runscan is not a function;at setTimeout callback function

TypeError: this.runscan is not a function

runscan: function(){

wx.scanCode({

onlyFromCamera: false, //可以从相册中调用照片

success: (res) => {

let unit8Arr = new Uint8Array(wx.base64ToArrayBuffer(res.rawData))

let encodedString = String.fromCharCode.apply(null, unit8Arr)

let decodeString = decodeURIComponent(escape((encodedString)))

let wlyzmsign = false

for (let x = 0; x < this.data.wlyzm.length; x++) {

if (this.data.wlyzm[x] == decodeString) {

wlyzmsign = true

break

}

}

if (wlyzmsign) {

wx.showToast({

title: '该产品已扫描!',

duration: 2000,

mask: true,

icon: 'loading',

})

setTimeout(function () {

console.log("执行此此")

this.runscan()//执行此行时

}, 2000

)

return

}

else {

this.data.wlyzm.push(decodeString)

}


回答关注问题邀请回答
收藏

1 个回答

  • 灵芝
    灵芝
    2019-10-08

    这种情况可以检查一下this的指向

    2019-10-08
    有用
    回复
登录 后发表内容
问题标签