TypeError: this is not a function at IntroJs._introExitCallback
TypeError: this is not a function at IntroJs._introExitCallback
我正在尝试将 div 传递给 intro.onexit() 上的 showOff,但出现此错误。
TypeError: this.hideStep is not a function
at IntroJs._introExitCallback (http://localhost:8100/build/main.js:511:18)
at IntroJs._exitIntro (http://localhost:8100/build/vendor.js:120298:31)
at HTMLDivElement.overlayLayer.onclick [as __zone_symbol__ON_PROPERTYclick] (http://localhost:8100/build/vendor.js:121508:20)
at HTMLDivElement.H (http://localhost:8100/build/polyfills.js:3:23950)
at t.invokeTask (http://localhost:8100/build/polyfills.js:3:15660)
at Object.onInvokeTask (http://localhost:8100/build/vendor.js:5125:33)
at t.invokeTask (http://localhost:8100/build/polyfills.js:3:15581)
at r.runTask (http://localhost:8100/build/polyfills.js:3:10834)
at e.invokeTask [as invoke] (http://localhost:8100/build/polyfills.js:3:16794)
at p (http://localhost:8100/build/polyfills.js:2:27648)
我在试图通过 menuCtrl.close() 时也遇到了这个错误。menuCtrl.close() 我必须将它声明到他的函数 intro() 中才能让它工作。我在想,那是因为我正在调用一个组件的函数,所以我实际上必须创建一个组件来将 false 传递给 ?
我现在有点迷茫,我正在学习,也许我的定义有误。
这是我的代码
public step1 = true;
hideStep(){
this.step1 = false;
}
intro() {
let intro = introJs.introJs();
let menuCtrl = this.menuCtrl;
intro.setOptions({
steps: [
{
intro: "Hello!! we want to give you some recommendations"
},
{
element: '#step1',
intro: "You can see the profile settings, just tapping in your profile picture",
position: 'bottom'
},
{
element: '#step2',
intro: "You can see the profile settings, just tapping in your profile picture",
position: 'bottom'
}
]
});
intro.start();
intro.onexit(function() {
menuCtrl.close();
this.hideStep();
});
}
ngAfterViewInit(): void {
this.intro();
}
尝试使用粗箭头函数代替方法函数,这是this
关键字问题:
intro.onexit(() => {
menuCtrl.close();
this.hideStep();
});
方法函数的this
关键字指的是它所在函数的所有者
我正在尝试将 div 传递给 intro.onexit() 上的 showOff,但出现此错误。
TypeError: this.hideStep is not a function
at IntroJs._introExitCallback (http://localhost:8100/build/main.js:511:18)
at IntroJs._exitIntro (http://localhost:8100/build/vendor.js:120298:31)
at HTMLDivElement.overlayLayer.onclick [as __zone_symbol__ON_PROPERTYclick] (http://localhost:8100/build/vendor.js:121508:20)
at HTMLDivElement.H (http://localhost:8100/build/polyfills.js:3:23950)
at t.invokeTask (http://localhost:8100/build/polyfills.js:3:15660)
at Object.onInvokeTask (http://localhost:8100/build/vendor.js:5125:33)
at t.invokeTask (http://localhost:8100/build/polyfills.js:3:15581)
at r.runTask (http://localhost:8100/build/polyfills.js:3:10834)
at e.invokeTask [as invoke] (http://localhost:8100/build/polyfills.js:3:16794)
at p (http://localhost:8100/build/polyfills.js:2:27648)
我在试图通过 menuCtrl.close() 时也遇到了这个错误。menuCtrl.close() 我必须将它声明到他的函数 intro() 中才能让它工作。我在想,那是因为我正在调用一个组件的函数,所以我实际上必须创建一个组件来将 false 传递给 ?
我现在有点迷茫,我正在学习,也许我的定义有误。
这是我的代码
public step1 = true;
hideStep(){
this.step1 = false;
}
intro() {
let intro = introJs.introJs();
let menuCtrl = this.menuCtrl;
intro.setOptions({
steps: [
{
intro: "Hello!! we want to give you some recommendations"
},
{
element: '#step1',
intro: "You can see the profile settings, just tapping in your profile picture",
position: 'bottom'
},
{
element: '#step2',
intro: "You can see the profile settings, just tapping in your profile picture",
position: 'bottom'
}
]
});
intro.start();
intro.onexit(function() {
menuCtrl.close();
this.hideStep();
});
}
ngAfterViewInit(): void {
this.intro();
}
尝试使用粗箭头函数代替方法函数,这是this
关键字问题:
intro.onexit(() => {
menuCtrl.close();
this.hideStep();
});
方法函数的this
关键字指的是它所在函数的所有者