我有一个在 JSFiddle 中运行良好的 IntroJS 演示.
当我将它与我的应用程序合并时,“单击我测试 IntroJS”按钮返回:
Uncaught ReferenceError: intro is not defined at HTMLButtonElement.onclick
- 我检查了是否通过 codepen CDN 加载了正确的 IntroJS css 和 JS 库。
- 我检查了函数的拼写。测试警报按钮正确触发..
- 我试过了
<body>
和 Codepen HTML head 部分中的其他 JSfiddle 包装器。我以前将代码片段从 Codepen 移到 JSfiddle,并且知道常见的错误。
我认为这是一个范围问题,但我不确定下一步该怎么做。
JS 在这里,在第 381 行
intro = introJs();
intro.setOptions({
'showStepNumbers': false
});
intro.start();
function testAlert() {
alert("alert");
};
按钮在这里:
<button onclick="intro.start();">Click me to Test IntroJS</button>
full app is here , 按钮半按下:
最佳答案
codepen 示例 (https://codepen.io/Teeke/pen/mRgWLg) 中的问题是第 355 行存在 JavaScript 错误:
setText(playButton, "播放");
尚 undefined variable playButton。这会阻止其余的 JavaScript 工作。一旦我注释掉所有对 playButton 的引用,intro.js 代码就会按预期执行。
关于javascript - IntroJS, Uncaught ReferenceError ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42275329/