Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过MVC4上的NuGet生成意外URL路径的jQuery_Jquery_Asp.net Mvc 4_Nuget - Fatal编程技术网

通过MVC4上的NuGet生成意外URL路径的jQuery

通过MVC4上的NuGet生成意外URL路径的jQuery,jquery,asp.net-mvc-4,nuget,Jquery,Asp.net Mvc 4,Nuget,我正在从事一个新的MVC项目,该项目使用BootstrapV3 通过NuGet,我通过以下操作获得了最新版本的jQuery: 安装jQuery包 然后我将jQuery(尝试缩小和取消缩小)拖到页面上,如下所示: <!-- JS --> <script src="~/Scripts/jquery-2.0.3.js"></script> <script src="~/Scripts/easing.js"></script&

我正在从事一个新的MVC项目,该项目使用BootstrapV3

通过NuGet,我通过以下操作获得了最新版本的jQuery:

安装jQuery包

然后我将jQuery(尝试缩小和取消缩小)拖到页面上,如下所示:

    <!-- JS -->
    <script src="~/Scripts/jquery-2.0.3.js"></script>
    <script src="~/Scripts/easing.js"></script>
    <script src="~/Scripts/bootstrap.js"></script>
    <script src="~/Scripts/ddlevelsmenu.js"></script>
    <script src="~/Scripts/flexslider.js"></script>
    <script src="~/Scripts/jquery.prettyPhoto.js"></script>
    <script src="~/Scripts/custom.js"></script>

    @RenderSection("scripts", required: false)

    </body>
</html>

@RenderSection(“脚本”,必需:false)
当我运行我的应用程序时,我得到jQuery的以下奇怪路径,我不知道为什么

路径“../home/~/Scripts/…”无效,必须是“../Scripts/…”

使用以下命令更改代码:

<script src="/Scripts/jquery-2.0.3.js"></script>
<script src="/Scripts/easing.js"></script>
<script src="/Scripts/bootstrap.js"></script>
<script src="/Scripts/ddlevelsmenu.js"></script>
<script src="/Scripts/flexslider.js"></script>
<script src="/Scripts/jquery.prettyPhoto.js"></script>
<script src="/Scripts/custom.js"></script>

或者,如果需要绝对路径:

<script src="@Url.Content("~/Scripts/jquery-2.0.3.js")"></script>
<script src="@Url.Content("~/Scripts/easing.js")"></script>
<script src="@Url.Content("~/Scripts/bootstrap.js")"></script>
<script src="@Url.Content("~/Scripts/ddlevelsmenu.js")"></script>
<script src="@Url.Content("~/Scripts/flexslider.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.prettyPhoto.js")"></script>
<script src="@Url.Content("~/Scripts/custom.js")"></script>

路径“../home/~/Scripts/…”无效,必须是“../Scripts/…”

使用以下命令更改代码:

<script src="/Scripts/jquery-2.0.3.js"></script>
<script src="/Scripts/easing.js"></script>
<script src="/Scripts/bootstrap.js"></script>
<script src="/Scripts/ddlevelsmenu.js"></script>
<script src="/Scripts/flexslider.js"></script>
<script src="/Scripts/jquery.prettyPhoto.js"></script>
<script src="/Scripts/custom.js"></script>

或者,如果需要绝对路径:

<script src="@Url.Content("~/Scripts/jquery-2.0.3.js")"></script>
<script src="@Url.Content("~/Scripts/easing.js")"></script>
<script src="@Url.Content("~/Scripts/bootstrap.js")"></script>
<script src="@Url.Content("~/Scripts/ddlevelsmenu.js")"></script>
<script src="@Url.Content("~/Scripts/flexslider.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.prettyPhoto.js")"></script>
<script src="@Url.Content("~/Scripts/custom.js")"></script>


这不应该是必需的。Razor v2完全支持基于根的呈现,无需使用Url.Content。这是不必要的。Razor v2完全支持基于根的呈现,无需使用Url.Content。你确定你在用MVC4吗?这是MVC3的升级项目吗?仅供参考,除非您愿意放弃IE8和更早版本的兼容性,否则不应该使用jQuery2.x。在IE8完全被弃用之前,您需要使用jQuery1.9.x分支。不可能!非常感谢,我不知道新的jQuery不支持IE8。至于MVC4,我很确定我是,但是我如何确认呢?检查Views目录中的Web.config,并查找razor程序集的版本号。您应该看到System.Web.WebPages.Razor.Configuration.HostSection、System.Web.WebPages.Razor、Version=2.0.0.0、Culture=neutral、PublicKeyToken=31BF3856AD364E35jQuery 1.9.x和2.x在功能上是相同的。它们保持同步,但1.9.x仍支持低于IE9的IE版本,而2.x已删除旧版浏览器支持。您确定要使用MVC4吗?这是MVC3的升级项目吗?仅供参考,除非您愿意放弃IE8和更早版本的兼容性,否则不应该使用jQuery2.x。在IE8完全被弃用之前,您需要使用jQuery1.9.x分支。不可能!非常感谢,我不知道新的jQuery不支持IE8。至于MVC4,我很确定我是,但是我如何确认呢?检查Views目录中的Web.config,并查找razor程序集的版本号。您应该看到System.Web.WebPages.Razor.Configuration.HostSection、System.Web.WebPages.Razor、Version=2.0.0.0、Culture=neutral、PublicKeyToken=31BF3856AD364E35jQuery 1.9.x和2.x在功能上是相同的。它们保持同步,但1.9.x仍然支持低于IE9的IE版本,而2.x已经删除了传统浏览器支持。