我正在尝试在我的流星应用程序中使用intro.js。
import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
// import introJs from 'intro.js';
var introJs = require('intro.js');
import './main.html';
.....//some code here
Template.hello.events({
'click button'(event, instance) {
// increment the counter when button is clicked
instance.counter.set(instance.counter.get() + 1);
},
'click #introjs'(e,i){
console.log("call me");
introJs("#introjs").start();
}
});
但是我给了
TypeError:introJs不是函数
我该如何解决这个问题? 感谢。
答案 0 :(得分:1)
尝试:introJs.introJs().start()
。那样做。
这是因为intro.js文件代码是如何编写的,请在console.log()
var上使用introJs
进行检查。
更多相关信息:Why does require('intro.js') export an object with just introJs?
答案 1 :(得分:0)
在你的html文件中,你必须在你想要介绍处理的html元素中添加一个像data-intro这样的介绍元素。
":" + timestamp.getNanos ();
在你的js文件上,确保导入intro.js和intro.css
<template name=hello>
<a href='http://google.com/' class='introjsclass' data-intro='Hello step one!'></a>
</template