我试图在intro.onexit()上将div传递给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)
我尝试使用this.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();
}
答案 0 :(得分:2)
尝试使用胖箭头功能代替方法功能,这是this
关键字问题:
intro.onexit(() => {
menuCtrl.close();
this.hideStep();
});
方法函数的this
关键字是指