2014-09-02 154 views
0

我在ASP.NET MVC创建了一个布局,我使用的脚本包加载jQuery库,但没有加载jQuery的。的mvc剃须刀捆

我的布局是这样的:

<!DOCTYPE html> 
<html> 
<head> 
    <meta charset="utf-8" /> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
    <title>@ViewBag.Title - My ASP.NET Application</title> 
    @Styles.Render("~/Content/css") 
    @Scripts.Render("~/bundles/modernizr") 
</head> 
<body> 
    @Scripts.Render("~/bundles/jquery") 
    @Scripts.Render("~/bundles/jqueryval") 
    @Scripts.Render("~/bundles/bootstrap") 
    @RenderSection("scripts", required: false) 
</body> 
</html> 

,我的包文件是

bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
         "~/Scripts/jquery-{version}.js")); 

请帮帮我!

+0

怎么做你的服务器端代码是什么样子? – avidenic 2014-09-02 06:50:31

+0

+1 ...需要查看您的BundleConfig.cs。你为什么认为它没有被加载?也许展示一个如何在视图中使用jQuery的例子。 – 2014-09-02 06:59:13

+0

后你束(上面的代码是罚款) – 2014-09-02 06:59:27

回答

4

你的代码有问题的是你是否正确,包括束正确即,有可能是您的bundleconfig文件的问题或者你是不是在视图中正确包括捆绑。

使用@section scripts{ }.cshtmlViews如下所示: -

@section scripts{ 
    <script type="text/javascript"> 
    $(document).ready(function() { 

    }); 
    </script> 
} 
+0

布局不能使用脚本部分 – 2014-09-02 06:59:12

+0

@ MehdiHaghshenas..i想提问越来越麻烦贴膜束在视图中没有布局。 – 2014-09-02 07:00:20

+0

如果想要多次使用脚本该怎么做? – 2014-09-02 07:03:09