MVC4 Bundle 中的 {version} 通配符 [英] {version} wildcard in MVC4 Bundle
问题描述
在 MVC 4 中,我们有包.在定义包时,我们可以对文件夹中的所有文件使用 * 等通配符.
In MVC 4 we have bundles. While defining the bundles we can use wildcards like * for all files in a folder.
在下面的例子中,-{version}
是什么意思?
In the example below what does -{version}
mean?
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
}
推荐答案
-{version}
基本上映射到一个版本 regex,或者更准确地说:(d+(?:.d+){1,3})
.
使用 *
往往会占用太多资源,例如,如果你捆绑了 jquery*
,那也会包括 jquery-ui
,这可能会搞乱订购.但是使用 jquery-{version}.js
可以让您避免每次升级 jquery 时都必须更新包定义.
The -{version}
basically maps to a version regex, or to be precise: (d+(?:.d+){1,3})
.
Using *
tends to grab too much, for example if you bundle jquery*
, that will include jquery-ui
as well which might mess up the ordering. But using jquery-{version}.js
would let you avoid having to update your bundle definition every time you upgrade jquery.
其他注意事项:
{version}
仅适用于路径的最后一部分——基本上是文件名——而不是目录.- 同一文件夹中的多个版本的 jquery 都会被追上.
{version}
only works for the last part of the path--basically the file name--not a directory.- multiple version of jquery in the same folder will all get caught up.
这篇关于MVC4 Bundle 中的 {version} 通配符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!