您可以通过在 Angular 应用的工作区文件(也就是在您的项目的根目录中)scripts
中向您的应用项目添加一个属性来将 JavaScript 文件添加到您的 Angular 应用:angular.json
{
"version": 1,
// ...
"projects": {
"my-app": {
// ...
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
// ...
"scripts": [
// JavaScript file goes here
"js/le.min.js",
// Note: The `scripts` property accepts an array of objects or an array of strings
// See https://github.com/angular/angular-cli/blob/c5de8e3b0e5c1499a0a17da0208297cd82b36095/packages/angular_devkit/build_angular/src/browser/schema.json#L390-L419 for more info
]
// ...
}
// ...
}
// ...
}
}
// ...
}
或者,您可以使用以下ng config
命令进行设置:
# Replace my-app with your actual project name in your angular.json file
ng config projects.my-app.architect.build.options.scripts[0] js/le.min.js