TypeError: this.runscan is not a function?出现此问题
发布于 6 年前 作者 fxue 14973 次浏览 来自 官方Issues

这段代码在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 回复

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

回到顶部