我在这里尝试了以下步骤: Step with click functionality in intro.js
以获得在步骤中触发的功能。我尚未成功执行该函数,但该教程仍在运行。最终目标是使该功能触发按钮单击。谢谢你的帮助。
<script type="text/javascript">
function startIntro(){
var intro = introJs();
intro.setOptions({
steps: [
{
intro: "Welcome to the page!",
onchange: function(){
console.log("test");
},
onbeforechange: function() {
console.log("before");
}
},
{
element: '#step1',
intro: "You can start doing something by clicking the New Item button."
},
{
element: '.thefilter',
intro: "You can filter any of the stock items in the table by using the search fields ",
position: 'bottom'
}
]
});
intro.start();
}
</script>
<a href="javascript:void(0);" onclick="startIntro();"><img style="position:fixed;" src="help.png" /></a>
答案 0 :(得分:2)
我在示例中错过了一些东西,这些东西给了我所需的指导。
这是更新的代码。
TLDR;删除了步骤中的内联onchange并将其附加在intro.start之前。有效!
<script type="text/javascript">
function startIntro(){
var intro = introJs();
intro.setOptions({
steps: [
{
intro: "Welcome to the page!"
},
{
element: '#step1',
intro: "You can start doing something by clicking the New Item button."
},
{
element: '.thefilter',
intro: "You can filter any of the stock items in the table by using the search fields ",
position: 'bottom'
}
]
});
intro.onbeforechange(function () {
if (this._currentStep === 2) {
console.log('what is happening')
return false;
}
});
intro.start();
}
</script>
<a href="javascript:void(0);" onclick="startIntro();"><img style="position:fixed;" src="help.png" /></a>