2017-06-11 99 views
0

我是非常新的反应,并且在使用本机反应方面没有足够的知识,所以我使用create-react-appreactjs:导入时出错uikit.min.js

我试图使用UIKit作为框架,但我无法让它工作。由于UIKit的NPM模块仅支持其2.x版本,因此我试图使用它的3.x(来自http://www.getuikit.com/)。我在我的一个组件中导入JS文件(uikit.min.js),但编译失败。

我包括在该文件中import * as uikit from 'uikit.min.js';这编译时会弹出:

./src/assets/js/uikit.min.js 
    Line 3: 'define' is not defined   no-undef 
    Line 3: 'define' is not defined   no-undef 
    Line 4: Unexpected use of 'location' no-restricted-globals 
    Line 4: Unexpected use of 'location' no-restricted-globals 
    Line 5: Unexpected use of 'location' no-restricted-globals 
    Line 5: 'DocumentTouch' is not defined no-undef 
    Line 5: 'MSGesture' is not defined  no-undef 

Search for the keywords to learn more about each error. 

也许我做错了,但我怎么能导入此我使用的UIKit V3?

+0

你或许可以将其包含在你的HTML文件作为脚本依赖 –

+0

@ShubhamKhatri试过,但我需要使用UIKit中的功能,如'UIkit.modal(“...”)。切换()'。 –

回答

0

首先用npm npm install uikit安装UIkit。然后:

import UIkit from 'uikit' 

,并记住,从文档反应只能与数据属性,引用:

阵营将与纯数据UK- *前缀工作。

+0

之前无法做到这一点,因为uikit的npm模块不是3.x,但很可爱,3天前有更新。谢谢你。 –

+0

很高兴帮助。干杯。 – cssBlaster21895