asp.net-mvc-4 – 如何在asp.net MVC4查看页面中包含javascript代码?
发布时间:2020-07-09 08:14:57 所属栏目: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 – 绑定ListView InsertItemTemplate中的DropDownL
- ASP.NET和System.Diagnostics跟踪 – 我错过了什么,或者这是
- ASP.NET JSON字符串与实体类的互转换示例代码
- asp.net – 如何打破VB.NET中的“if”块
- asp.net-mvc-4 – 在哪里可以找到WebMatrix.WebData.WebSec
- 数组 – 如何在vbscript中实现具有可变大小的数组
- ASP.NET如何确定是否排队请求?
- asp.net-mvc – RequireHttps导致Amazon Elastic Load Bala
- asp.net-mvc-3 – 在MVC Razor View中使用If语句
- asp.net – MVC 4导出到CSV – 另存为对话框在Chrome和Fire
推荐文章
站长推荐
- asp.net-mvc-3 – Orchard CMS DataAnnotations
- asp.net – 我应该在Web应用程序中嵌入CSS / Jav
- asp.net-mvc – DropDownListFor在编辑视图上不重
- asp.net – Oracle.ManagedDataAccess:TNS:无法
- 在ASP.NET RadioButtonList ListItem上设置CSS类
- asp.net-mvc – 只发布控制器
- ASP.Net WebAPI与Ajax进行跨域数据交互时Cookies
- 进程是经典ASP可以存储会话状态的唯一方法吗?
- asp.net – 脚本标签和链接标签进入asp:内容或外
- 实现ASP.NET多文件上传程序代码
热点阅读
