首页 文章

如何以角度管理js文件

提问于
浏览
0

我正在开发一个MEAN应用程序,我的文件夹结构如下:

enter image description here

我在/ angular / src / assets / js下添加了一个js文件,用于一些jQuery的东西 .

为此,我使用npm安装了jQuery .

现在我需要通过 angular.cli.json 文件调用该js文件 .

angular.cli.json:

"apps": [
{
  "root": "angular/src",
  "outDir": "angular/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"
  ],
  "scripts": [
     "../node_modules/jquery/dist/jquery.min.js",
     "../src/assets/js/custom.js"
  ],

由于我将根指向“angular / src”,因此存在将jquery.min.js包含在脚本部分中的问题,该部分位于“mean / node_modules /”下并以“未找到”错误结束 .

angular.cli.json文件在“angular / src”根路径中查找“node_modules / jquery / dist / jquery.min.js” .

有没有办法解决这个问题而不改变我的文件夹结构?

需要别人的宝贵帮助 .

2 回答

相关问题