jquery - 如何在 ionic 3 中使用 shepherd 和 jquery?
问题描述
我正在尝试在我的 ionic 3 应用程序中构建巡回演出,因此我选择Shepherd来实现它。
但是在ionic 3中,它是一个打字稿框架,所以我们不能直接在html文件中调用jQuery,而是在.ts文件中。牧羊人有一个函数调用'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 访问,但如果 id 选择器只是您的问题,那么您可以通过以下方式访问它。
const tour = new Shepherd.Tour();
tour.addStep('example-step', {
text: 'Testing',
attachTo: '#shepherdElement'
});
tour.start();
推荐阅读
- python - 检测文本中的小写首字母缩写词
- javascript - 如何使用小书签抓取部分 URL
- node.js - UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server on first connect with Heroku server
- sql-server - “-”附近的语法不正确
- vue.js - Webpack 没有插入 vue 构建
- python-3.x - 如何找到客户每次访问之间的天数差异
- sql - 如何在不更新表格的情况下更改字段?
- angular - 如何动态更改 ag-Grid 的选项?
- linux - 如何从终端 A 发送在终端 B 中打开的程序的命令?
- reactjs - 将 React HTTP 流量重定向到 HTTPS GCP