2017-08-04 66 views
1

我試圖添加自定義jqueryUI datepicker組件到angular4項目。目前我用普通的jquery,html和css開發。我想將該組件添加到angular4。 我已經嘗試過,但在運行npm時會出現錯誤。jQueryUI與angular4

我的jQuery UI的日期選擇器(定製rangepicker)

enter image description here

這是我如何導入jQueryUI的,以angular4

"apps": [ 
{ 
    "root": "src", 
    "outDir": "dist", 
    "assets": [ 
    "assets", 
    "favicon.ico" 
    ], 
    "index": "index.html", 
    "main": "main.ts", 
    "polyfills": "polyfills.ts", 
    "test": "test.ts", 
    "tsconfig": "tsconfig.app.json", 
    "testTsconfig": "tsconfig.spec.json", 
    "prefix": "app", 
    "styles": [ 
    "styles.css", 
    "../node_modules/jquery-ui/../themes/base/all.css", 
    "../node_modules/bootstrap/dist/css/bootstrap.min.css" 
    ], 
    "scripts": ["../node_modules/jquery/dist/jquery.min.js", 
    "../node_modules/jqueryui/jquery-ui.js", 
    "../node_modules/bootstrap/dist/js/bootstrap.min.js"], 
    "environmentSource": "environments/environment.ts", 
    "environments": { 
    "dev": "environments/environment.ts", 
    "prod": "environments/environment.prod.ts" 
    } 
} 

],

這是我得到的錯誤命令提示符

enter image description here

回答

5
"scripts": ["node_modules/jquery/dist/jquery.min.js","node_modules/jqueryui/jquery-ui.js", 
"node_modules/bootstrap/dist/js/bootstrap.min.js"] 

如果沒有充分的路徑嘗試這方面的工作。

npm uninstall -g angular-cli @angular/cli 
npm cache clean 
npm install -g [email protected] 

"styles": [ 
    "fullpath/styles.css", 
    "node_modules/jquery-ui/../themes/base/all.css", 
    "node_modules/bootstrap/dist/css/bootstrap.min.css" 
], 
+0

它工作了jquiery.min.js但在同樣的方式jquery.min.css犯規進口。它給出同樣的錯誤。有沒有什麼不同的方式來導入CSS? – Lahi2010

+0

我已經更新了答案並嘗試給出css的完整路徑。 – 2017-08-05 04:12:58