简体   繁体   English

您可以 go 到 Angular IntroJS 事件中的特定步骤吗?

[英]Can you go to specific step within Angular IntroJS event?

It seems if I try to go to a particular step from within the IntroJS onexit event, it gets very confused and doesn't show the correct step and highlighted element.似乎如果我尝试 go 到 IntroJS onexit事件中的特定步骤,它会变得非常混乱并且不显示正确的步骤和突出显示的元素。

I have my steps setup via json, i have 8 steps我通过 json 设置了我的步骤,我有 8 个步骤

[{
    element:
    title:
    intro:
}]

If the user closes the tour by clicking the X (skip) button, I need to show a final message, so I have set it up to go to a specific step via the onexit如果用户通过单击 X(跳过)按钮关闭游览,我需要显示最后一条消息,因此我已通过onexit将其设置为 go 到特定步骤

 introJS.onexit(() => {
    introJS.goToStep(8).start();
 }

Can we not do it here?我们不能在这里做吗? Basically what happens is it shows the correct intro text but its highlighting a completely different element from a different step.基本上发生的情况是它显示了正确的介绍文本,但它突出显示了来自不同步骤的完全不同的元素。 Is this because I'm calling itself within the event?这是因为我在活动中自称吗? How would one go about doing this if possible?如果可能的话,一个 go 如何做到这一点?

I have even tried setting the options to a new set of steps - and splicing those steps to only include the single step I need - this does not work either.我什至尝试将选项设置为一组新的步骤 - 并将这些步骤拼接为仅包含我需要的单个步骤 - 这也不起作用。

introJs.setOptions({
    steps: this.steps[lastStep]
});
introJs.start();

Thanks to @GRD I was able to solve this by instead using the onbeforeexit event and making sure to return false as such感谢@GRD,我能够通过使用onbeforeexit事件并确保返回 false 来解决这个问题

introJs.onbeforeexit(() => {
   introJs.goToStepNumber(lastStep).start();
   introJs.refresh(true);
   return false;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM