asp.net-mvc-4 – 如何在asp.net MVC4查看页面中包含javascript代码?
发布时间:2020-05-22 11:17:45 所属栏目: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 – {get;组; }在ViewModel中使用
- asp.net – 从两个表(join)获取数据,并使用linq返回结果
- asp.net-mvc – 如何用asp.net mvc 3和ListBoxFor显示多个选
- asp.net – 为什么WebMethod访问会话状态没有EnableSession
- asp.net – 在调用异步方法时不使用等待来防止死锁
- asp.net-mvc – ASP.Net MVC 4通用主要困难
- asp.net-mvc – 使用Razor在ASP.NET MVC 4中防止@ Html.Lab
- asp.net-mvc – 在asp.net mvc中使用Checkbox提交表单
- asp.net-mvc – ASP.NET MVC 2预览2:区域重复控制器问题
- asp.net – Linq to Sql – 根据环境变量动态设置连接字符串
推荐文章
站长推荐
- 加速ASP.Net网站或应用程序
- asp.net – 小数点后尾数为零
- asp.net – WCF – 找到了该合同的多个端点配置
- asp.net-mvc-3 – 基于字符串创建ViewBag属性
- asp.net-mvc-4 – 将ninject dependecyResolver用
- asp.net-mvc-3 – @ Html.TextBoxFor文本框在验证
- asp.net – 您如何看待Postgres和Firebird数据库
- 使用AspNetPager与GridView完成分页
- asp.net-mvc – ASP.Net T4MVC文件未自行更新
- asp.net-mvc – 在应用程序洞察中设置用户名
热点阅读
