本文转自:https://blog.csdn.net/s31415926_004/article/details/84256587

其实这篇文章是给自己看的,以后忘记怎么做回来还能看一下哈哈哈哈哈哈哈哈。。。嗝

点击左侧菜单栏只刷新局部,局部就用iframe。

首先先建layout页,建左侧菜单栏,然后下面的@RenderBody()

<div class="layui-side layui-bg-black">
<div class="layui-side-scroll">
<!-- 左侧导航区域(可配合layui已有的垂直导航) -->
<ul class="layui-nav layui-nav-tree" lay-filter="test">

<li class="layui-nav-item layui-nav-itemed Card">
<a class="" href="#">名片审核</a>
</li>

<li class="layui-nav-item Project">
<a href="#">项目审核</a>
</li>

<li class="layui-nav-item Funds"><a href="#">需求审核</a></li>
</ul>
</div>
</div>
<div class="layui-body">
@RenderBody()
@RenderSection("scripts", required: false)
</div>
    然后在最后写上js用于点击跳转,上面的@RenderSection("scripts", required: false)和下面的#demoAdmin都在另一个页面中,也就是放iframe的页面

<script>
//JavaScript代码区域
layui.use('element', function () {
var $ = layui.jquery
, element = layui.element;
});
$(".Card").click(function () {
$("#demoAdmin").attr("src", "/Admin/CardManagement")
});
$(".Project").click(function () {
$("#demoAdmin").attr("src", "/Admin/ProjectManagement")
});
$(".Funds").click(function () {
$("#demoAdmin").attr("src", "/Admin/FundsManagement")
});
</script>
    新建HomeController,新建Index页面

@{
Layout = null;
Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}

<iframe src="/Admin/CardManagement" frameborder="0" id="demoAdmin" style="width: 100%; height: 100%;"></iframe>

@section scripts{
<script>
reHeight();
$(window).resize(function () {
reHeight();
});
//设置iframe高度
function reHeight() {
var bodyHeight = $(window).height();
bodyHeight = bodyHeight - 107;
if (bodyHeight<400) {
bodyHeight = 400;
}
$("#demoAdmin").height(bodyHeight);
}
</script>
    引用一下上面的layout。

其他页面引用Layout = "~/Areas/Admin/Views/Shared/_LayoutPage.cshtml";

我把css和js引用都放在了另一个layout里,所以我需要引用一下,否则页面会乱。
---------------------
作者:PiNosan
来源:CSDN
原文:https://blog.csdn.net/s31415926_004/article/details/84256587
版权声明:本文为博主原创文章,转载请附上博文链接!

[转]layui点击左侧导航栏,实现不刷新整个页面,只刷新局部的更多相关文章

  1. 修改layui的后台模板的左侧导航栏可以伸缩

    原生的左侧导航栏代码: <div class="layui-side layui-bg-black"> <div class="layui-side-s ...

  2. CI框架后台添加左侧导航栏出现的一系列问题

  3. dedecms左侧导航栏不显示问题

    dedecms左侧导航栏不显示问题 在做织梦项目时,经常会碰到后台左侧导航栏不显示的问题,如下所示: ​ 这主要是由于文件权限不足造成的.有两种方法 第一种:把 /data 文件夹全部改成 777 权 ...

  4. MFC office2007风格设置左侧导航栏 [转]

    当基础的框架搭好以后,我想为其添加一个左侧导航栏,过程如下:在框架类的头文件添加一个导航栏参数: CMFCOutlookBar m_navigation; 为了完善功能,在导航栏里面我添加了一个CTr ...

  5. ElementUI+命名视图实现复杂顶部和左侧导航栏

    在了解了命名视图的用途后,发现用命名视图来实现复杂导航更加省力.更多知识请参考这里 这里只说明重要配置内容,其他内容配置请参考上一篇初始版本: ElementUI 复杂顶部和左侧导航栏实现 或参考文末 ...

  6. ElementUI 复杂顶部和左侧导航栏实现

    描述:如图 项目路径如下图所示: 代码实现: 首先在store.js中添加两个状态: import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vue ...

  7. Boostrap导航栏跳转到其他页面或外部链接

    想要在boostrap下增加一个标签a,并设置其href属性来实现跳转功能(具体是想在导航栏中添加,点击某个导航栏部件时跳转至其他页面),但是发现事情并不是想象中的那么简单: “Bootstrap为这 ...

  8. Vue 事件监听实现导航栏吸顶效果(页面滚动后定位)

    Vue 事件监听实现导航栏吸顶效果(页面滚动后定位) Howie126313 关注 2017.11.19 15:05* 字数 100 阅读 3154评论 0喜欢 0 所说的吸顶效果就是在页面没有滑动之 ...

  9. 前端(各种demo)二:左侧导航栏的折叠和打开(不使用js)基础版和升级版

    1.给div设置定位. 复习一下—— css中position有五种属性: static:默认值,没有定位 absolute:绝对定位,相对于父级元素进行定位 relative:相对定位 fixed: ...

随机推荐

  1. vue项目中引入mint-ui的方式(全部引入与按需引入)

    参考哦 https://blog.csdn.net/qq_36742720/article/details/83620584 https://jingyan.baidu.com/article/c1a ...

  2. 性能测试学习 第八课--LR12中针对WebServices协议的三种脚本开发模式

    一,webservices协议简介 webservices是建立可交互操作的分布式应用程序的新平台,它通过一系列的标准和协议来保证程序之间的动态连接, 其中最基本的协议包括soap,wsdl,uddi ...

  3. Hibernate4集成spring4报错----No Session found for current thread

    在编写一个Hibernate4集成spring4的小demo的时候出现了该错误: org.hibernate.HibernateException: No Session found for curr ...

  4. [Swift]LeetCode165. 比较版本号 | Compare Version Numbers

    Compare two version numbers version1 and version2.If version1 > version2 return 1; if version1 &l ...

  5. [Swift]LeetCode203. 移除链表元素 | Remove Linked List Elements

    Remove all elements from a linked list of integers that have value val. Example: Input: 1->2-> ...

  6. [Swift]LeetCode479. 最大回文数乘积 | Largest Palindrome Product

    Find the largest palindrome made from the product of two n-digit numbers. Since the result could be ...

  7. [Swift]LeetCode726. 原子的数量 | Number of Atoms

    Given a chemical formula (given as a string), return the count of each atom. An atomic element alway ...

  8. [Swift]LeetCode752. 打开转盘锁 | Open the Lock

    You have a lock in front of you with 4 circular wheels. Each wheel has 10 slots: '0', '1', '2', '3', ...

  9. [Swift]LeetCode882. 细分图中的可到达结点 | Reachable Nodes In Subdivided Graph

    Starting with an undirected graph (the "original graph") with nodes from 0 to N-1, subdivi ...

  10. [Swift]LeetCode973. 最接近原点的 K 个点 | K Closest Points to Origin

    We have a list of points on the plane.  Find the K closest points to the origin (0, 0). (Here, the d ...