MVC3 快速入门第三节 添加一个视图.docx

上传人:b****2 文档编号:2253271 上传时间:2023-05-03 格式:DOCX 页数:13 大小:338.65KB
下载 相关 举报
MVC3 快速入门第三节 添加一个视图.docx_第1页
第1页 / 共13页
MVC3 快速入门第三节 添加一个视图.docx_第2页
第2页 / 共13页
MVC3 快速入门第三节 添加一个视图.docx_第3页
第3页 / 共13页
MVC3 快速入门第三节 添加一个视图.docx_第4页
第4页 / 共13页
MVC3 快速入门第三节 添加一个视图.docx_第5页
第5页 / 共13页
MVC3 快速入门第三节 添加一个视图.docx_第6页
第6页 / 共13页
MVC3 快速入门第三节 添加一个视图.docx_第7页
第7页 / 共13页
MVC3 快速入门第三节 添加一个视图.docx_第8页
第8页 / 共13页
MVC3 快速入门第三节 添加一个视图.docx_第9页
第9页 / 共13页
MVC3 快速入门第三节 添加一个视图.docx_第10页
第10页 / 共13页
MVC3 快速入门第三节 添加一个视图.docx_第11页
第11页 / 共13页
MVC3 快速入门第三节 添加一个视图.docx_第12页
第12页 / 共13页
MVC3 快速入门第三节 添加一个视图.docx_第13页
第13页 / 共13页
亲,该文档总共13页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

MVC3 快速入门第三节 添加一个视图.docx

《MVC3 快速入门第三节 添加一个视图.docx》由会员分享,可在线阅读,更多相关《MVC3 快速入门第三节 添加一个视图.docx(13页珍藏版)》请在冰点文库上搜索。

MVC3 快速入门第三节 添加一个视图.docx

MVC3快速入门第三节添加一个视图

ASP.NETMVC3快速入门-第三节添加一个视图

 

ASP.NETMVC3快速入门-第三节添加一个视图

分类:

 ASP.NETMVC2011-04-1016:

27 4145人阅读 评论

(2) 收藏 举报

3.1  添加一个视图

   在本节中我们修改HelloWorldController类,以便使用视图来向客户端展示HTML格式的响应结果。

我们使用ASP.NETMVC3中新增的Razor视图引擎来创建视图。

Razor视图模板文件的后缀名为.cshtml,它提供了一种简洁的方式来创建HTML输出流。

Razor视图大大减少了在书写视图模板文件时所需要输入的字符,提供了一个最快捷,最简便的编码方式。

   这里,我们在HelloWorldController类的Index方法中添加使用一个视图。

在修改前的Index方法中返回一个字符串,我们修改这个方法来使它返回一个视图,代码如下所示。

publicActionResultIndex()

{

      returnView();

}

   这段代码表示Index方法使用一个视图模板来在浏览器中生成HTML格式的页面文件。

接着,让我们来添加一个Index方法所使用的视图模板。

在Index方法中点击鼠标右键,然后点击“添加视图”,将会弹出一个“添加视图”对话框。

 

图3-1添加视图

图3-2 添加视图对话框

   在该对话框中,不做任何修改,直接点击添加按钮,观察解决方案资源管理器中,在MvcMovie项目下的Views文件夹下创建了一个HelloWorld文件夹,并且在该文件夹中创建了一个Index.cshtml文件,同时该文件呈打开状态,如图3-3所示。

图3-3 视图模板文件被创建并呈打开状态

   让我们在该文件中追加一些文字,代码如代码清单3-1所示。

   代码清单3-1Index.cshtml视图模板文件

@{

    ViewBag.Title="首页";

}

首页

这是我的第一个视图模板

   运行应用程序,输入地址“http:

//localhost:

xxxx/HelloWorld”。

由于在Index方法中并没有做任何事情,只是简单地一行代码—“returnView()”,该行代码表示我们使用一个视图模板文件来在浏览器中展示响应结果。

因为我们并没有显式指定使用哪个视图模板文件,所以使用了默认的Views文件夹下的HelloWorld文件夹下的Index.cshtml视图模板文件。

该视图模板文件中只有简单的两行文字,在浏览器中的显示结果如图3-4所示。

图3-4 在浏览器中显示视图

   看上去还不错,但是请注意,该网页的标题为“首页”,但是网页中的大标题文字却为“我的MVC应用程序”,需要修改一下。

3.2  修改视图,修改应用程序的页面布局 

   首先,让我们修改页面大标题中的“我的MVC应用程序”文字。

这段文字是所有页面中的公共大标题,在这个应用程序中,虽然所有页面中都显示了这个共同的大标题,但只有一处地方对其进行了设置。

打开解决方案资源管理器中Views文件夹下的Shared文件夹下的_Layout.cshtml文件。

该文件被称为布局页面,位于公有文件夹Shared下,被所有其他网页所共用。

图3-5 公有布局页面 

   布局模板页允许你统一在一个地方指定整个Web应用程序或Web网站的所有HTML页面的布局方法。

请注意文件底部的“@RenderBody()”代码行。

@RenderBody()是一个占位符,代表了所有你创建出来的实际应用的视图页面,在这里统一指定。

将布局模板文件中的“我的MVC应用程序”修改为“我的MVCMovie应用程序”。

代码如下所示。

    

我的 MVCMovie 应用程序

   运行应用程序,注意网页中的大标题被修改为“我的MVCMovie应用程序”。

点击“关于”链接,你可以看见“关于”页面中的大标题也被修改为“我的MVCMovie应用程序”。

由此可以看出一旦修改了布局页面中的某处地方,该修改将会被应用到所有页面中。

图3-6在布局页面中修改了网页中显示的大标题

   完整的_Layout.cshtml文件中的代码如代码清单3-2所示。

   代码清单3-2_Layout.cshtml文件中的完整代码

DOCTYPEhtml>

    

    @ViewBag.Title

    

type="text/css"/>

    

type="text/javascript">

    

        

            

                

我的 MVCMovie 应用程序

            

            

                @Html.Partial("_LogOnPartial")

            

            

                

                    

  • @Html.ActionLink("主页","Index","Home")
  •                     

  • @Html.ActionLink("关于","About","Home")
  •                 

                

            

            

                @RenderBody()

                

                

            

        

     

       现在,让我们修改Index视图页面的标题。

       打开Views文件夹下的HelloWorld文件夹下的Index.cshtml文件。

    这里我们修改两处地方:

    首先,修改浏览器中的标题,然后修改

    标签中的小标题文字。

    修改后代码如代码清单3-3所示。

       代码清单3-3修改后的Index.cshtml视图模板文件

    @{

        ViewBag.Title="电影清单";

    }

    我的电影清单

    这是我的第一个视图模板

     

       ViewBag对象的Title属性代表了显示该页面时的浏览器中的标题文字。

    让我们回头看一下布局模板文件,在该文件的区段中的标签中使用了这个值来作为浏览器中的网页标题。</p><p>同时,通过这种方法,你可以很容易地在你的视图模板文件与布局模板文件之间进行参数的传递。</p><p>   运行应用程序,在地址栏中输入“http:</p><p>//localhost:</p><p>xxxx/HelloWorld”,注意浏览器中的网页标题,页面中的小标题文字都变为修改后的标题文字(如果没有发生变化的话,则可能你的网页被缓存住了,可以按Ctrl+F5键来在重新刷新页面时取消缓存)。</p><p>   同时也请注意_Layout.cshtml文件中的占位符中的内容被替换成了Index.cshtml视图模板中的内容,所以浏览器中展示的是一个单一的HTML文件。</p><p>浏览器中的运行结果如图3-7所示。</p><p>图3-7修改了标题后的Index视图模板文件</p><p>   此处,我们的数据(“这是我的第一个视图模板”文字)是被直接书写在文件中的,也就是说我们使用到了MVC应用程序的“V”(视图View)与“C”(控制器Controller)。</p><p>接下来,我们讲解一下如何创建一个数据库并从该数据库中获取模型数据。</p><p>3.3  将控制器中的数据传递给视图</p><p>   在我们使用数据库并介绍模型之前,首先我们介绍一下如何将控制器中的信息传递给视图。</p><p>浏览器接收到一个URL请求后,将会调用控制器类来进行响应。</p><p>你可以在控制器类中进行对接收到的页面参数进行处理的代码,你可以在控制器类中书写从数据库中获取数据的代码,你也可以在控制器类中书写代码来决定返回给客户端什么格式的响应文件。</p><p>控制器可以利用视图模板文件来生成HTML格式的响应文件并显示在浏览器中。</p><p>   控制器类负责提供视图模板文件在生成HTML格式的响应文件时所需要的任何数据或对象。</p><p>一个视图模板文件不应该执行任何业务逻辑,也不应该直接和数据库进行交互。</p><p>它只能和控制器类进行交互,获取控制器类所提供给它的数据,这样可以使你的代码更加清晰,容易维护。</p><p>   现在在我们的应用程序中,HelloWorldController控制器类中的Welcome方法带有两个参数—name与numTimes,Welcome方法直接向浏览器输出这两个参数的参数值。</p><p>这里,我们修改该方法使其不再直接输出数据,而是使用一个视图模板。</p><p>该视图模板将生成一个动态的响应流,这意味着我们需要将数据从控制器类传递给视图以便利用该数据来生成该响应流。</p><p>我们在该控制器类中将视图模板所需要的数据送入一个ViewBag对象中,该对象可以被视图模板直接接收。</p><p>   打开HelloWorldController.cs文件,修改Welcome方法,在该方法中为ViewBag对象添加一个Message属性与NumTimes属性,并且将属性值分别设定为经过处理后的name参数值与numTimes参数值。</p><p>ViewBag对象是一个动态对象,你可以为它添加任何属性并赋上属性值。</p><p>在未赋值之前该属性是不生效的,直到你赋值为止。</p><p>修改后的HelloWorldController.cs文件中的代码如代码清单3-4所示。</p><p>   代码清单3-4修改后的HelloWorldController.cs文件</p><p>usingSystem.Web;</p><p>usingSystem.Web.Mvc;</p><p>namespaceMvcMovie.Controllers</p><p>{</p><p>    publicclassHelloWorldController:</p><p>Controller</p><p>    {</p><p>        //</p><p>        //GET:</p><p>/HelloWorld/</p><p>        publicActionResultIndex()</p><p>        {</p><p>            returnView();</p><p>        }</p><p>        //</p><p>        //GET:</p><p>/HelloWorld/Welcome/</p><p>        publicActionResultWelcome(stringname,intnumTimes=1)</p><p>        {</p><p>            ViewBag.Message="Hello"+name;</p><p>            ViewBag.NumTimes=numTimes;</p><p>            returnView();</p><p>        }</p><p>    }</p><p>}</p><p>   现在ViewBag对象中已经包含了数据,它将被自动传递给视图。</p><p>  </p><p>   接下来,我们需要创建一个Welcome视图模板。</p><p>在“调试”菜单中,点击“生成MvcMovie”将应用程序进行编译,如图3-8所示。</p><p>图3-8 编译应用程序</p><p>   接下来,在Welcome方法中点击鼠标右键,然后点击“添加视图”,弹出对话框如图3-9所示。</p><p>图3-9为Welcome方法添加视图</p><p>   在该对话框中不做任何修改,直接点击添加按钮,View文件夹下的HelloWorld文件假种自动被创建了一个Welcome.cshtml文件,打开该文件,在<h2>元素下添加代码,让浏览器显示URL地址中传入的name参数中设定的文字,显示次数等于URL地址中传入的numTimes参数中设定的次数。</p><p>修改后的Welcome.cshtml文件中的代码如代码清单3-5所示。</p><p>   代码清单3-5修改后的Welcome.cshtml文件</p><p>@{</p><p>    ViewBag.Title="Welcome";</p><p>}</p><p><h2>Welcome</h2></p><p><ul></p><p>@for(inti=0;i<ViewBag.NumTimes;i++)</p><p>{</p><p>    <li>@ViewBag.Message</li></p><p>}</p><p></ul></p><p>  运行应用程序,并且在地址栏中输入“http:</p><p>//localhost:</p><p>xx/HelloWorld/Welcome?</p><p>name=Scott&numtimes=4”,该地址栏中的页面参数将会自动传递给控制器。</p><p>控制器将会把这些参数值放入ViewBag对象中并且传递给视图。</p><p>视图再在浏览器中显示这些数据。</p><p>图3-10视图中显示从控制器类中传递过来的数据</p><p>   这里,我们使用了模型“M”的一种方式,但是不是数据库的方式。</p><p>在下一节中,我们将创建一个数据库,并且介绍如何对该数据库中的数据进行处理。</p><p></p> </div> <div class="readmore" onclick="showmore()" style="background-color:transparent; height:auto; margin:0px 0px; padding:20px 0px 0px 0px;"><span class="btn-readmore" style="background-color:transparent;"><em style=" font-style:normal">展开</em>阅读全文<i></i></span></div> <script> function showmore() { $(".readmore").hide(); $(".detail-article").css({ "height":"auto", "overflow": "hidden" }); } $(document).ready(function() { var dh = $(".detail-article").height(); if(dh >100) { $(".detail-article").css({ "height":"100px", "overflow": "hidden" }); } else { $(".readmore").hide(); } }); </script> </div> <script> var defaultShowPage = parseInt("20"); var id = "2253271"; var total_page = "13"; var mfull = false; var mshow = false; function DownLoad() { window.location.href='https://m.bingdoc.com/d-2253271.html'; } function relate() { var reltop = $('#relate').offset().top-50; $("html,body").animate({ scrollTop: reltop }, 500); } </script> <div id="relate" class="container" style="padding:0px 0px 15px 0px; margin-top:20px; border:solid 1px #dceef8"> <div style=" font-size: 16px; background-color:#e5f0f7; margin-bottom:5px; font-weight: bold; text-indent:10px; line-height: 40px; height:40px; padding-bottom: 0px;">相关资源</div> <div id="relatelist" style="padding-left:5px;"> <ul> <li><em class="docx"/></em><a target="_parent" href="https://m.bingdoc.com/p-4571423.html" title="如何快速入门一个陌生知识领域.docx">如何快速入门一个陌生知识领域.docx</a> </li><li><em class="docx"/></em><a target="_parent" href="https://m.bingdoc.com/p-16135078.html" title="如何快速入门电子技术.docx">如何快速入门电子技术.docx</a> </li><li><em class="docx"/></em><a target="_parent" href="https://m.bingdoc.com/p-6735282.html" title="如何快速入门一个陌生知识领域Word文档格式.docx">如何快速入门一个陌生知识领域Word文档格式.docx</a> </li><li><em class="docx"/></em><a target="_parent" href="https://m.bingdoc.com/p-11181064.html" title="学习的技术如何快速入门一个陌生知识领域.docx">学习的技术如何快速入门一个陌生知识领域.docx</a> </li><li><em class="pptx"/></em><a target="_parent" href="https://m.bingdoc.com/p-1437260.html" title="如何做好一场培训(快速入门技巧篇).pptx">如何做好一场培训(快速入门技巧篇).pptx</a> </li><li><em class="docx"/></em><a target="_parent" href="https://m.bingdoc.com/p-14046451.html" title="如何快速了解一个行业.docx">如何快速了解一个行业.docx</a> </li><li><em class="docx"/></em><a target="_parent" href="https://m.bingdoc.com/p-10683394.html" title="如何快速了解一个行业分析.docx">如何快速了解一个行业分析.docx</a> </li><li><em class="pptx"/></em><a target="_parent" href="https://m.bingdoc.com/p-1568299.html" title="如何做好一场培训(快速入门技巧篇)PPT文件格式下载.pptx">如何做好一场培训(快速入门技巧篇)PPT文件格式下载.pptx</a> </li><li><em class="docx"/></em><a target="_parent" href="https://m.bingdoc.com/p-3133228.html" title="如何快速搭建一个BI数据分析平台.docx">如何快速搭建一个BI数据分析平台.docx</a> </li><li><em class="docx"/></em><a target="_parent" href="https://m.bingdoc.com/p-13050956.html" title="Dubbo入门如何搭建一个Demo框架.docx">Dubbo入门如何搭建一个Demo框架.docx</a> </li> </ul> </div> </div> <div class="container" style="padding:0px 0px 15px 0px; margin-top:20px; border:solid 1px #dceef8"> <div style=" font-size: 16px; background-color:#e5f0f7; margin-bottom:5px; font-weight: bold; text-indent:10px; line-height: 40px; height:40px; padding-bottom: 0px;">猜你喜欢</div> <div id="relatelist" style="padding-left:5px;"> <ul> <li><em class="docx"></em> <a href="https://m.bingdoc.com/p-537888.html" target="_parent" title="高中学生会竞选部长演讲稿.docx">高中学生会竞选部长演讲稿.docx</a></li> <li><em class="docx"></em> <a href="https://m.bingdoc.com/p-537889.html" target="_parent" title="运动员广播稿.docx">运动员广播稿.docx</a></li> <li><em class="docx"></em> <a href="https://m.bingdoc.com/p-537890.html" target="_parent" title="关于养文明习惯,做文明学生的演讲稿范文(精选5篇).docx">关于养文明习惯,做文明学生的演讲稿范文(精选5篇).docx</a></li> <li><em class="docx"></em> <a href="https://m.bingdoc.com/p-537891.html" target="_parent" title="计生个人工作总结.docx">计生个人工作总结.docx</a></li> <li><em class="docx"></em> <a href="https://m.bingdoc.com/p-537892.html" target="_parent" title="公司保险经纪人工作总结.docx">公司保险经纪人工作总结.docx</a></li> <li><em class="docx"></em> <a href="https://m.bingdoc.com/p-537893.html" target="_parent" title="种子藏在哪里教案.docx">种子藏在哪里教案.docx</a></li> <li><em class="docx"></em> <a href="https://m.bingdoc.com/p-537894.html" target="_parent" title="监理工作总结范文.docx">监理工作总结范文.docx</a></li> <li><em class="docx"></em> <a href="https://m.bingdoc.com/p-537895.html" target="_parent" title="最新高三毕业典礼校长幽默的演讲.docx">最新高三毕业典礼校长幽默的演讲.docx</a></li> <li><em class="docx"></em> <a href="https://m.bingdoc.com/p-537896.html" target="_parent" title="关于3-6岁儿童学习与发展指南的心得.docx">关于3-6岁儿童学习与发展指南的心得.docx</a></li> </ul> </div> </div> <div style=" font-size: 16px; background-color:#e5f0f7; margin-top:20px; font-weight: bold; text-indent:10px; line-height: 40px; height:40px; padding-bottom: 0px; margin-bottom:10px;"> 相关搜索</div> <div class="widget-box pt0" style="border: none; padding:0px 5px;"> <ul class="taglist--inline multi"> <li class="tagPopup"><a target="_parent" class="tag tagsearch" rel="nofollow" href="https://m.bingdoc.com/search.html?q=MVC3">MVC3</a></li> <li class="tagPopup"><a target="_parent" class="tag tagsearch" rel="nofollow" href="https://m.bingdoc.com/search.html?q=%e5%bf%ab%e9%80%9f%e5%85%a5%e9%97%a8%e7%ac%ac%e4%b8%89%e8%8a%82">快速入门第三节</a></li> <li class="tagPopup"><a target="_parent" class="tag tagsearch" rel="nofollow" href="https://m.bingdoc.com/search.html?q=%e6%b7%bb%e5%8a%a0%e4%b8%80%e4%b8%aa%e8%a7%86%e5%9b%be">添加一个视图</a></li> <li class="tagPopup"><a target="_parent" class="tag tagsearch" rel="nofollow" href="https://m.bingdoc.com/search.html?q=%e5%bf%ab%e9%80%9f">快速</a></li> <li class="tagPopup"><a target="_parent" class="tag tagsearch" rel="nofollow" href="https://m.bingdoc.com/search.html?q=%e5%85%a5%e9%97%a8">入门</a></li> <li class="tagPopup"><a target="_parent" class="tag tagsearch" rel="nofollow" href="https://m.bingdoc.com/search.html?q=%e4%b8%89%e8%8a%82">三节</a></li> <li class="tagPopup"><a target="_parent" class="tag tagsearch" rel="nofollow" href="https://m.bingdoc.com/search.html?q=%e6%b7%bb%e5%8a%a0">添加</a></li> <li class="tagPopup"><a target="_parent" class="tag tagsearch" rel="nofollow" href="https://m.bingdoc.com/search.html?q=%e4%b8%80%e4%b8%aa">一个</a></li> <li class="tagPopup"><a target="_parent" class="tag tagsearch" rel="nofollow" href="https://m.bingdoc.com/search.html?q=%e8%a7%86%e5%9b%be">视图</a></li> </ul> </div> <div style=" font-size: 16px; background-color:#e5f0f7; font-weight: bold; text-indent:10px; line-height: 40px; height:40px; padding-bottom: 0px; margin-bottom:10px;"> 资源标签</div> <div class="widget-box pt0" style="border: none; padding:0px 5px;"> <ul class="taglist--inline multi"> <li class="tagPopup"><a class="tag tag0" href="https://m.bingdoc.com/mark/ruhekuaisurumenyige.html" >如何快速入门一个</a></li><li class="tagPopup"><a class="tag tag1" href="https://m.bingdoc.com/mark/mvc3kuaisurumendisanjietianjiayigeshitukuaisu.html" >MVC3快速入门第三节添加一个视图快速</a></li> <li class="tagPopup"><a target="_parent" class="tag tag1" href="https://m.bingdoc.com/mark/ruhekuaisudajianyige.html">如何快速搭建一个</a></li> <li class="tagPopup"><a target="_parent" class="tag tag2" href="https://m.bingdoc.com/mark/ruherumenfpga.html">如何入门FPGA</a></li> <li class="tagPopup"><a target="_parent" class="tag tag3" href="https://m.bingdoc.com/mark/kuaisurumenjiqiao.html">快速入门技巧</a></li> <li class="tagPopup"><a target="_parent" class="tag tag4" href="https://m.bingdoc.com/mark/zhishilingyuitto.html">知识领域itto</a></li> <li class="tagPopup"><a target="_parent" class="tag tag0" href="https://m.bingdoc.com/mark/kuaisurumenjiqiao.html">快速入门技巧</a></li> <li class="tagPopup"><a target="_parent" class="tag tag1" href="https://m.bingdoc.com/mark/ruhekuaisudajianyige.html">如何快速搭建一个</a></li> <li class="tagPopup"><a target="_parent" class="tag tag2" href="https://m.bingdoc.com/mark/ruhekuaisubianzhijishu.html">如何快速编制技术</a></li> </ul> </div> <br /> <div > 当前位置:<a target="_parent" href="https://m.bingdoc.com/">首页</a> > <a href="https://m.bingdoc.com/booklist-00006.html">人文社科</a><span> > </span><a href="https://m.bingdoc.com/booklist-0000600001.html">法律资料</a> </div> <br /> <div class="cssnone"> <iframe title="来源" src="https://m.bingdoc.com/BookRead.aspx?id=U3GXkdWVNR0%3d" frameborder="0" style="width: 0px; height: 0px"> </iframe> </div> <span id="LabelScript"></span> <script src="https://mstatic.bingdoc.com/JS/bootstrap-collapse.js"></script> </form> <div class="siteInner_bg" style="margin-top: 40px; border: solid 0px red; margin-left: 0px; margin-right: 0px;"> <div class="siteInner"> <p style="text-align: center;">copyright@ 2008-2023 冰点文库 网站版权所有</p><p style="text-align: center;">经营许可证编号:<a href="http://beian.miit.gov.cn/" target="_blank">鄂ICP备19020893号-</a>2</p><script>var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?f82ede2a6dd69d4ed35205d3eb25b840"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })();</script> </div> </div> <div class="trnav clearfix" id="navcontent" style="display: none; background-color:#3a71b1; "> <div class="trlogoside" id="navlogo" style="display: none;"> <a href="https://m.bingdoc.com/" title="冰点文库"><img src="https://www.bingdoc.com/images/logo_bd.png" alt="冰点文库"></a> <div class="trnavclose" id="navclose"> <span></span> </div> </div> <div class="navcontainer"> <div class="row"> <ul class="nav navbar-nav trnavul headercontent" id="navigation" style="margin:20px 0 0px;"> <li><a target="_parent"href="https://m.bingdoc.com/login.aspx">登录</a></li> <li><a target="_parent"href="https://m.bingdoc.com/">首页 </a></li> <li><a target="_parent"href="https://m.bingdoc.com/booklist-0.html">资源分类 </a></li> <li><a target="_parent"href="https://m.bingdoc.com/UserManage/Recharge.aspx?f=0"><img src="https://m.bingdoc.com/images/s.gif" alt="new" class="hottip1">升级会员 <img src="https://www.bingdoc.com/FileUpload/Images/48520fea-bc98-41ae-b183-84689c7075c9.gif" alt="new" class="hottip"></a></li> <li><a target="_parent"href="https://m.bingdoc.com/newslist.html">通知公告 </a></li> <li><a target="_parent"href="https://m.bingdoc.com/h-0.html">帮助中心 </a></li> </ul> </div> </div> </div> <script type="text/javascript"> function stopPropagation(e) { var ev = e || window.event; if (ev.stopPropagation) { ev.stopPropagation(); } else if (window.event) { window.event.cancelBubble = true;//兼容IE } } $("#navmore").click(function (e) { $("#navcontent").show(); $("#navlogo").show(); stopPropagation(e); var navcontentwidth = $("#navcontent").width(); $('#navcontent').css({ 'right': '-' + navcontentwidth + 'px' }); $("#navcontent").show().animate({ "right": 0 }, 300); }); $(document).bind('click', function () { var navcontentwidth = $("#navcontent").width(); $("#navcontent").animate({ 'right': '-' + navcontentwidth + 'px' }, 300, function () { $("#navcontent").hide(); }); $("#navlogo").fadeOut(300); }); $("#navcontent").click(function (e) { stopPropagation(e); }); $("#navclose").click(function (e) { var navcontentwidth = $("#navcontent").width(); $("#navcontent").animate({ 'right': '-' + navcontentwidth + 'px' }, 300, function () { $("#navcontent").hide(); }); $("#navlogo").fadeOut(300); }); </script> <script> function BaseShare(title, desc, imgUrl) { var link = "https://m.bingdoc.com/p-2253271.html"; if (wx) { wx.config({ debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 appId: 'wx3a9604896163fa38', // 必填,公众号的唯一标识 timestamp: '1719045978', // 必填,生成签名的时间戳 nonceStr: '17E62166FC8586DFA4D1BC0E1742C08B', // 必填,生成签名的随机串 signature: 'f57afacfa459eb7406b605106449b7cecff11c2b',// 必填,签名,见附录1 jsApiList: ['onMenuShareAppMessage', 'onMenuShareTimeline', 'updateAppMessageShareData', 'updateTimelineShareData', 'hideMenuItems'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2 //openTagList: ["wx-open-launch-weapp"]//H5打开小程序 }); wx.ready(function () { //需在用户可能点击分享按钮前就先调用 wx.hideMenuItems({// 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3 menuList: ['menuItem:share:qq', 'menuItem:favorite', 'menuItem:share:QZone', 'menuItem:share:email', 'menuItem:originPage', 'menuItem:readMode', 'menuItem:delete', 'menuItem:editTag', 'menuItem:share:facebook', 'menuItem:share:weiboApp', 'menuItem:share:brand'] }); var shareData = { title: title, // 分享标题 desc: desc,//这里请特别注意是要去除html link: link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 imgUrl: imgUrl, // 分享图标 }; wx.updateAppMessageShareData(shareData);//1.4 分享到朋友 wx.updateTimelineShareData(shareData);//1.4分享到朋友圈 }); } } function BaseShare(title, desc, imgUrl, link) { if (link=="") link = "https://m.bingdoc.com/p-2253271.html"; if (wx) { wx.config({ debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 appId: 'wx3a9604896163fa38', // 必填,公众号的唯一标识 timestamp: '1719045978', // 必填,生成签名的时间戳 nonceStr: '17E62166FC8586DFA4D1BC0E1742C08B', // 必填,生成签名的随机串 signature: 'f57afacfa459eb7406b605106449b7cecff11c2b',// 必填,签名,见附录1 jsApiList: ['onMenuShareAppMessage', 'onMenuShareTimeline', 'updateAppMessageShareData', 'updateTimelineShareData', 'hideMenuItems'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2 //openTagList: ["wx-open-launch-weapp"]//H5打开小程序 }); wx.ready(function () { //需在用户可能点击分享按钮前就先调用 wx.hideMenuItems({// 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3 menuList: ['menuItem:share:qq', 'menuItem:favorite', 'menuItem:share:QZone', 'menuItem:share:email', 'menuItem:originPage', 'menuItem:readMode', 'menuItem:delete', 'menuItem:editTag', 'menuItem:share:facebook', 'menuItem:share:weiboApp', 'menuItem:share:brand'] }); var shareData = { title: title, // 分享标题 desc: desc,//这里请特别注意是要去除html link: link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致 imgUrl: imgUrl, // 分享图标 }; wx.updateAppMessageShareData(shareData);//1.4 分享到朋友 wx.updateTimelineShareData(shareData);//1.4分享到朋友圈 }); } } </script> <script> $(document).ready(function () { var arr = $(".headercontent"); for (var i = 0; i < arr.length; i++) { (function (index) { var url = "https://m.bingdoc.com/header.aspx"; $.get(url + "?t=" + (new Date()).valueOf(), function (d) { try { arr.eq(index).empty().html(d); } catch (e) { } try { arr.html(d); } catch (e) { } }); })(i); } }); </script> <script src="https://mstatic.bingdoc.com/js/jquery.lazyload.js"></script> <script charset="utf-8"> $("img.lazys").lazyload({ threshold: 200, effect: "fadeIn" }); </script> </body> </html>