我在将一个jQuery级联下拉组件嵌入到我的Angular 6项目时遇到了问题 . 我在尝试运行_1096627时遇到错误:
错误:ENOENT:没有这样的文件或目录,打开C:\ nodeprojects \ node_modules \ jquery \ dist \ jquery.min.js .
以下是我将jQuery添加到Angular 6的步骤:
- 跑
npm install jquery
'并验证了 jquery.min.js
在上面列出的路径中 .
-
已修改
angular.json
(Angular 6不再具有'angular-cli.json'文件)并在'scripts []'部分中添加了jquery.min.js
文件的相对路径 . -
我正在使用
app.component
作为目标组件 . 在app.component.ts
中,我输入了declare var $: any;
并在export class AppComponent implements OnInit()
中输入了jquery自定义组件函数 .
我试图嵌入Angular的jquery组件位于https://jsfiddle.net/brohjoe/zgc0n1q5/1/
HTML已输入 app.component.html
. 我删除了对脚本src的引用,因为如上所述, angular.json
中列出了缩小的jquery库,并且如上所述,custom.js代码嵌入在_1096641中 .
运行localhost:4200后,将显示的唯一ui元素是没有数据的下拉列表 .