我写了以下代码(模拟):
module.exports = {
test() {
console.log('test')
},
iffer(nb) {
if (nb !== 0) {
this.test()
}
}
}
我收到错误“测试不是函数”。
并尝试了以下方法:
let that = this
module.exports = {
test() {
console.log('test')
},
iffer(nb) {
if (nb !== 0) {
that.test()
}
}
}
该解决方案仍然无法正常工作,因为 JavaScript 模块默认开启了严格模式。有谁知道这个问题的解决方案?