2016-09-05 179 views
2

我想在我的流星应用程序中使用intro.js。如何在流星1.4.1.1中使用intro.js表单npm包?

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 is not a function

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

+0

我也有同样的问题。你找到什么了吗? –

+1

搜索时,我得到了这个https://github.com/zhouzhuojie/meteor-introjs链接,看看它是否有益,也让我知道。 –

+0

@Arjun Chaudhary不,我想找到一种方法。在流星论坛上看到你的这篇文章[link](https://forums.meteor.com/t/not-working-bootstraptour-with-meteor-1-4/28859/6) –

回答

0

在您的html文件中,您必须在任何想要介绍处理的位置添加一个介绍元素,如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(); 
    } 
}); 
+0

感谢@Vinay Prabhakaran留意你,但我给这个错误:TypeError:introJs不是函数 –

+0

尝试更新的语法 –