Hopscotch onClose巡回演出功能

Hopscotch onClose tour function

本文关键字:功能 巡回演出 onClose Hopscotch      更新时间:2023-09-26

我正在使用Hopscotch创建一个巡更,我想为用户创建一个功能,让他们在点击页面后进行或退出巡更。

我正试图创建一个onClose函数,但是我被卡住了。

var tour = {
   id: "businesstour-hopscotch",
   steps: [
{
  title: "Welcome",
  content: "This is the new business profile page, click next to have a quick tour.",
  target: document.querySelector('#companyname'),
  placement: "right",
  xOffset: -380,
  yOffset: 52,
  onClose: function() {
    window.location = '/';
  }
},

等等,但它不起作用。也没有显示结束巡演的按钮。任何想法都会有所帮助!

根据我对文档的理解,onClose定义是一个"Tour Option",应该这样声明,而不是在步骤中:

var tour = {
   id: "businesstour-hopscotch",
   onClose: function() {
       window.location = '/';
   },
   steps: [{
       title: "Welcome",
       content: "This is the new business profile page, click next to have a quick tour.",
       target: document.querySelector('#companyname'),
       placement: "right",
       xOffset: -380,
       yOffset: 52
     }]
};

我正在像这样初始化我的,这适用于用户点击教程右上角的"x"。但是,当用户在教程的最后一步单击"完成"按钮时,我并没有看到触发此事件。