1

我正在使用linkedin hopscotch在Angular应用程序中创建游览,在此应用程序中,根据某些条件,我需要将游览跳过到特定步骤。

所以我有这样的事情:

hopscotch.registerHelper("skipToStep", function(stepIdx) {
 console.log(hopscotch.getCurrStepNum());
 console.log(hopscotch.getState());
 hopscotch.showStep(stepIdx);
 console.log(hopscotch.getCurrStepNum());
 console.log(hopscotch.getState());
});

然后我将回调放在游览的步骤中

steps[1].onNext = ["skipToStep", 5]

当我在步骤 1 中单击下一步时,控制台的输出是:

2
graphTour:1

5 
graphTour:5

但是出现的步骤是步骤[2],有谁知道跳到特定步骤的正确方法是什么???

4

1 回答 1

1

Did you try without registering the helper?

I would call the showStep directly in the onNext callback. Something like this:

toolsTour = {
  id: "graphTour", 
  steps: [
    {   title: "Home/Start",
        content: "Some text bla bla.",
        target: "someDiv",
        placement: "right" ,
        onNext: function() {
            hopscotch.showStep(5);      
        }
    },
    ...

It works fine for me.

于 2014-01-24T08:41:57.900 回答