我正在使用angular-cli。我为scripts.bundle.js
文件收到404错误。
这可能与我在angular-cli
的脚本中添加的文件有关,如下所示。如何访问angular-cli脚本中assets文件夹中的JavaScript文件。
"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": [
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
"styles.scss"
],
"scripts": [
"assets/js/slick.min.js",
"assets/js/bootstrap.min.js",
"assets/js/jquery.placeholder.min.js",
"assets/js/jquery-3.2.1.min.js",
"assets/js/plugins.js",
"assets/js/popper.min.js"
],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}],
答案 0 :(得分:0)
对于angular-8,还有另一种实现目标的方法-“如何访问JavaScript文件,这些文件位于angular-cli脚本的Assets文件夹中。”
只需转到角度项目根文件夹中的index.html文件。
并在结束body标签之前的底部添加:
<script src="assets/js/slick.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/jquery.placeholder.min.js"></script>
<script src="assets/js/jquery-3.2.1.min.js"></script>
<script src="assets/js/plugins.js"></script>
<script src="assets/js/popper.min.js"></script>