简体   繁体   English

如何在不知道Asp.Net Core中的正确名称的情况下包含js文件

[英]How to include js file without knowing proper name in Asp.Net Core

<script src="~/angular/runtime*"></script>
<script src="~/angular/polyfills*"></script>
<script src="~/angular/vendor*"></script>
<script src="~/angular/main*"></script>

在此输入图像描述

I want to add these scripts in my Layout page 我想在我的布局页面中添加这些脚本

As far as I can tell, the hashes in your js file names are caused by the --prod flag in the angular-cli. 据我所知,js文件名中的哈希值是由angular-cli中的--prod标志引起的。

You basically have to options here: 你基本上必须在这里选择:

  • remove the --prod flag 删除--prod标志
  • add --output-hashing none flag add --output-hashing none标志

That means you would end up with a build command similar to this: 这意味着你最终会得到一个与此类似的构建命令:

ng build --prod --output-hashing none

Please note, that the hashes serve a specific purpose: Cache-Busting. 请注意,哈希值用于特定目的:缓存 - 缓存。 Everytime you generate a new build, these hashes change and if you inject the script(s) automatically into a html file using the angular-cli, this has the benefit of not needing to check if you have to clear your cache and if the changes have been picked up by your browser or if they have been served from disk. 每次生成新构建时,这些哈希值都会发生变化,如果您使用angular-cli将脚本自动注入到html文件中,这样做的好处是无需检查是否必须清除缓存以及是否需要更改已被您的浏览器选中或者是否已从磁盘提供。

Documentation: https://angular.io/cli/build 文档: https//angular.io/cli/build

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM