reactjs:导入时出错 uikit.min.js

reactjs: Error in importing uikit.min.js

我是 React 的新手,不熟悉如何使用 React,所以我使用 create-react-app

我正在尝试使用 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?

首先使用 npm npm install uikit 安装 UIkit。那么:

import UIkit from 'uikit'

请记住,React 仅适用于数据属性,引用自文档:

React will work with data-uk-* prefixes only.