溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

MVC+EasyUI+三層新聞網站建立tabs標簽的示例分析

發(fā)布時間:2021-06-22 11:50:33 來源:億速云 閱讀:142 作者:小新 欄目:開發(fā)技術

小編給大家分享一下MVC+EasyUI+三層新聞網站建立tabs標簽的示例分析,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!

MVC新聞網站建立,完成tabs標簽的制作。

首先對 Center 進行一個簡單的布局

 <!--------------中間布局開始---------------->
  <div data-options="region:'center',title:'Center'" >
    <div class="easyui-tabs"  fit="true" id="tt">
      <div title="歡迎使用">
        <h2 >歡迎!</h2>
        <h2 > Welcome !</h2>
      </div>


    </div>

  </div>
  <!--------------中間布局結束--------------->

然后就是在js里面完成tabs的點擊事件實現(xiàn)了

其實center就是在div里面嵌入了一個iframe,所以最后返回的就是一個iframe

 <script type="text/javascript">
    $(function () {
      //tabs的點擊事件
      bindTabsEvent();
    });
    function bindTabsEvent() {
      $(".detail").click(function () {
        //拿到點擊標題
        var title = $(this).text();
        //拿到點擊的url
        var url = $(this).attr("url");
        //判斷標簽是否存在
        var isExt = $("#tt").tabs("exists", title);
        //如果存在則選中
        if (isExt) {
          $("#tt").tabs("select", title); //選中
          return;
        }
        //不存在就添加標簽
        $("#tt").tabs("add", {
          title: title,
          content: createTabContent(url),
          closable:true
        });
      });
    }
    function createTabContent(url) {
      return '<iframe src="' + url + '" scrolling="no" frameborder="0" width="100%" height="100%"></iframe>';
    }
  </script>

這里需要注意一點就是上面的detail是導航欄的類選擇器的值(這里的class一定要一樣)

MVC+EasyUI+三層新聞網站建立tabs標簽的示例分析

整個頁面代碼

@{
 Layout = null;
}

<!DOCTYPE html>

<html>
<head>
 <meta name="viewport" content="width=device-width" />
 <title>Index</title>
 <script src="~/Scripts/jquery-1.8.2.js"></script>
 <script src="~/Content/EasyUI/jquery.easyui.min.js"></script>
 <script src="~/Content/EasyUI/easyui-lang-zh_CN.js"></script>
 <link href="~/Content/EasyUI/themes/default/easyui.css" rel="external nofollow" rel="stylesheet" />
 <link href="~/Content/EasyUI/themes/icon.css" rel="external nofollow" rel="stylesheet" />
 <script type="text/javascript">
  $(function () {
   //tabs的點擊事件
   bindTabsEvent();
  });
  function bindTabsEvent() {
   $(".detail").click(function () {
    //拿到點擊標題
    var title = $(this).text();
    //拿到點擊的url
    var url = $(this).attr("url");
    //判斷標簽是否存在
    var isExt = $("#tt").tabs("exists", title);
    //如果存在則選中
    if (isExt) {
     $("#tt").tabs("select", title); //選中
     return;
    }
    //不存在就添加標簽
    $("#tt").tabs("add", {
     title: title,
     content: createTabContent(url),
     closable:true
    });
   });
  }
  function createTabContent(url) {
   return '<iframe src="' + url + '" scrolling="no" frameborder="0" width="100%" height="100%"></iframe>';
  }
 </script>
</head>
<body class="easyui-layout">
 <div data-options="region:'north',border:false" >north region</div>

 <!---------左側布局------------------------------------>

 <div data-options="region:'west',split:true,title:'West'" >
  <div class="easyui-accordion" >

   <div title="新聞管理" data-options="iconCls:'icon-ok'" >
    <a href="javascript:void(0)" rel="external nofollow" rel="external nofollow" class="detail" url="/AdminNewInfo/Index">新聞管理</a>
   </div>

   <div title="評論管理" data-options="iconCls:'icon-ok'" >
    <a href="javascript:void(0)" rel="external nofollow" rel="external nofollow" class="detail" url="/CommentInfo/Index">評論管理</a>
   </div>


  </div>


 </div>

 <!---------左側布局結束------------------------------------>


 <div data-options="region:'south',border:false" >south region</div>


 <!--------------中間布局開始---------------->
 <div data-options="region:'center',title:'Center'" >
  <div class="easyui-tabs"  fit="true" id="tt">
   <div title="歡迎使用">
    <h2 >歡迎!</h2>
    <h2 > Welcome !</h2>
   </div>


  </div>

 </div>
 <!--------------中間布局結束--------------->

</body>
</html>

看完了這篇文章,相信你對“MVC+EasyUI+三層新聞網站建立tabs標簽的示例分析”有了一定的了解,如果想了解更多相關知識,歡迎關注億速云行業(yè)資訊頻道,感謝各位的閱讀!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI