在MVC4捆绑{}版本通配符 [英] {version} wildcard in MVC4 Bundle

查看:157
本文介绍了在MVC4捆绑{}版本通配符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MVC 4,我们有包。在定义包,我们可以像使用通配符*对所有文件的文件夹中。

在下面做什么的例子 - {版本} 的意思是

公共静态无效RegisterBundles(BundleCollection包)
{
    bundles.Add(新ScriptBundle(〜/包/ jQuery的)。包括(
        〜/脚本/ jquery- {}版本的.js));
}


解决方案

- {版本} 基本映射到一个版本的正则表达式,或者是precise: (\\ d +(?:\\。\\ D +){1,3})。结果
使用 * 趋于如果捆绑 jQuery的* ,将包括的jQuery的UI 以及可能弄乱顺序。但是,使用 jquery- {}版本的.js 将让你避免每次升级的jQuery的时间来更新你的包定义。

其他注意事项:


  • {版本} 只适用于路径的最后一部分 - 基本文件名 - 不是一个目录。

  • 在同一文件夹中的jQuery的多个版本都将被套牢。

In MVC 4 we have bundles. While defining the bundles we can use wildcards like * for all files in a folder.

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"));
}

解决方案

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.

Additional things to note:

  • {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捆绑{}版本通配符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆