asp.net-mvc-4 – 如何在asp.net MVC4查看页面中包含javascript代码?
发布时间:2020-07-09 09:11:55 所属栏目:asp.Net 来源:互联网
导读:我是asp.net MVC4架构的新手,我对以下事情感到困惑,请帮助我. @Scripts.Render(~/bundles/jquery)@Scripts.Render(~/bundles/jqueryui)script type=text/javascript$(function () { $(#sections).tabs(); //here i
我是asp.net MVC4架构的新手,我对以下事情感到困惑,请帮助我. @Scripts.Render("~/bundles/jquery") @Scripts.Render("~/bundles/jqueryui") <script type="text/javascript"> $(function () { $("#sections").tabs(); //here i am getting error that Object[object object] has not method tabs }); </script> <div id="sections"> <ul> <li><a href="#section-1">section-1 </a></li> <li><a href="#section-2">section-2 </a></li> </ul> <div id="section-1"> section-1 content............ </div> <div id="section-2"> section-2 content............ </div> </div> 提前致谢…… 解决方法您可能已经包含了/ bundles / jquery包两次.查看/ Views / Shared / _Layout.cshtml文件.最后你可能有以下内容:@Scripts.Render("~/bundles/jquery") @RenderSection("scripts",required: false) </body> 所以jQuery包已经包含在你的页面中.您不应该在视图中第二次包含它.你只需要/ bundles / jqueryui包: @Scripts.Render("~/bundles/jqueryui") <script type="text/javascript"> $(function () { $("#sections").tabs(); //here i am getting error that Object[object object] has not method tabs }); </script> <div id="sections"> <ul> <li><a href="#section-1">section-1 </a></li> <li><a href="#section-2">section-2 </a></li> </ul> <div id="section-1"> section-1 content............ </div> <div id="section-2"> section-2 content............ </div> </div> 更新: 以下是视图结构可能如下所示的完整示例: @{ Layout = null; } <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" /> <title>Foo</title> <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" /> </head> <body> <div id="sections"> <ul> <li><a href="#section-1">section-1 </a></li> <li><a href="#section-2">section-2 </a></li> </ul> <div id="section-1"> section-1 content............ </div> <div id="section-2"> section-2 content............ </div> </div> @Scripts.Render("~/bundles/jquery") @Scripts.Render("~/bundles/jqueryui") <script type="text/javascript"> $("#sections").tabs(); </script> </body> </html> (编辑:鲜蔬坊站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – 使用类似MvcContrib Grid的东西在代码可读性
- asp.net – 转发器控件中的单选按钮列表
- asp.net-mvc – ASP.Net MVC:如何根据原始的Json数据创建一
- [你必须知道的.NET] 开篇有益
- LoginView中的ASP.NET LoginStatus不会触发LoggingOut事件
- asp.net 文章分页显示实现代码
- asp.net – 如何在MVC 3中设置图表系列颜色?
- ASP.NET成员:拒绝用户阻止CSS,页面无法正确呈现?
- asp.net – 无法加载文件或程序集App_Licenses
- asp.net+Ajax 文本文件静态分页实现代码
推荐文章
站长推荐
- 看美剧英文字幕学英语的利器深蓝英文字幕助手简介
- 谈谈.NET Core中基于Generic Host来实现后台任务
- asp.net – IIS 404自定义错误不能按预期工作
- asp.net-web-api – WebApi2属性路由404
- asp.net-mvc – 为什么DropDownListFor会在提交后
- 在ASP.NET中,什么决定了HostingEnvironment.IsDe
- 如何利用ASP.net IIS 7.5中的浏览器缓存
- asp.net-web-api – WebApi 2.1 PUT抛出错误415
- 如何解决.Net中冲突的程序集?
- asp.net中让Repeater和GridView支持DataPager分页
热点阅读