我想下载一个脚本并使用它而不是使用cdn
cdn链接是
< script src =“https://cdn.jsdelivr.net/npm/es6-object-assign@1.1.0/dist/object-assign-auto.min.js”>< / script> …
可能你没有在正确的地方脚本或相对路径“./js”是不正确的。
既然你已经标记了 angular 在你的帖子中,你不能在模板html中包含脚本。您可以将它们包含在index.html中以直接从cdn加载它们或下载并将它们包含在 scripts 数组 angular-cli.json
angular
scripts
angular-cli.json
如果你不使用角度,问题可能是 incorrect filename , incorrect folder 甚至是错的 relative 路径。
incorrect filename
incorrect folder
relative
将thr脚本添加到 angular.json 文件,在 scripts 部分。
angular.json
路径从文件夹的根开始,所以它应该是 js/encoding.js :
js/encoding.js
"build": { "builder": "@angular-devkit/build-angular:browser", "options": { ... "assets": [...], "styles": [...], "scripts": [ "js/encoding.js" ] },