[英]How to manage js files in angular
我正在开发MEAN应用,我的文件夹结构如下:
我在/ angular / src / assets / js下添加了一些jQuery内容的js文件。
为此,我已经使用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”。
有什么方法可以解决此问题而无需更改我的文件夹结构?
需要某人的宝贵帮助。
是。 从angular.cli.json中删除脚本链接,然后使用脚本标签将其包含在索引html中。
工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.