如何在meteor1.4.1.1中使用intro.jsforms的npm包?

我正在尝试在我的meteor应用程序中使用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不是函数

我如何解决这个问题? 谢谢。

试试: introJs.introJs().start() 。 那会做的。 这是因为如何编写intro.js文件代码,请使用console.log()introJs var进行检查。 更多关于这个: 为什么require('intro.js')只用introJs导出一个对象?

在你的html文件中,你必须添加一个intro元素,像data-intro到你想要介绍处理的html元素。

 <template name=hello> <a href='http://google.com/' class='introjsclass' data-intro='Hello step one!'></a> </template 

在你的js文件中,确保导入intro.js和intro.css

 import { Template } from 'meteor/templating'; import { ReactiveVar } from 'meteor/reactive-var'; import introJs from 'intro.js'; //var introJs = require('intro.js'); // you have to import the introjs css file import '/node_modules/path to your introjs css file'; import './main.html'; .....//some code here Template.hello.events({ 'click .introjsclass':function(event){ event.preventDefault(); console.log('call me'); introJs('.introjsclass').start(); } }); 
Interesting Posts