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



我对反应很陌生,并且不了解本机使用 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 只能使用 data-uk-* 前缀。

最新更新