【问题标题】:How to use shepherd with jquery in ionic 3?如何在 ionic 3 中使用 shepherd 和 jquery?
【发布时间】:2019-01-22 03:56:18
【问题描述】:

我正在尝试在我的 ionic 3 应用程序中构建巡回演出,因此我选择 Shepherd 来实现它。

但在ionic 3中,它是一个打字稿框架,所以我们不能直接在html文件中调用jQuery,而是在.ts文件中。而且shepherd有一个函数调用'addStep',比如

tour.addStep('example-step', {
    text: 'Testing',
    attachTo: '.example-css-selector bottom',
    classes: 'example-step-extra-class',
    buttons: [
       {
          text: 'Next',
          action: tour.next
       }
    ]
});

所以,我已经安装了 jQuery 和 shepherd 插件。但是在尝试下面的代码时,它不会起作用。

在 home.html 中

<p>Title</p>
<button id="shepherdElement">Click Me</button>

在 home.ts 中

const tour = new Shepherd.Tour();

tour.addStep('example-step', {
      text: 'Testing',
      attachTo: $('#shepherdElement')
  });

tour.start();

我希望游览会附加到#shepherdElement,但事实并非如此。

实物图

【问题讨论】:

    标签: jquery ionic-framework plugins


    【解决方案1】:

    我不确定通过 Jquery 访问,但如果 id 选择器只是您的问题,那么您可以通过以下方式访问它。

    const tour = new Shepherd.Tour();
    tour.addStep('example-step', {
      text: 'Testing',
      attachTo: '#shepherdElement'
      });
    tour.start();
    

    【讨论】:

      猜你喜欢
      • 2018-03-31
      • 2018-11-22
      • 2019-12-10
      • 2018-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多