2017-07-19 50 views
2

我很難在我的反應js組件中導入我的uikit.js。如何在不使用uikit組件的情況下在反應js中導入uikit js?

這是我的進口樣品中,uikit.css作品,但uikit.js提供了這樣那樣的錯誤:

import './uikit/css/uikit.css'; 
import './uikit/js/uikit.js'; 

    Line 5:  'define' is not defined   no-undef 
    Line 5:  'define' is not defined   no-undef 
    Line 573: 'DocumentTouch' is not defined no-undef 
    Line 1107: 'MSGesture' is not defined  no-undef 
    Line 5039: Unexpected use of 'location' no-restricted-globals 
    Line 5043: Unexpected use of 'location' no-restricted-globals 
    Line 6679: Unexpected use of 'location' no-restricted-globals 

回答

1

這不應該是一個問題。首先,與

npm i uikit --save

安裝的UIKit然後將其導入您的應用程序,就像任何其他程序包。
如果使用create-react-app,您在調用它src目錄,只是做

import '../node_modules/uikit/css/uikit.css'

否則判斷的深度和相應地調整相對路徑