1 Star 3 Fork 3

blank/layui官网静态

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
tab.html 29.33 KB
一键复制 编辑 原始数据 按行查看 历史
blank 提交于 2021-10-13 15:20 . 整理
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tab选项卡 - 页面元素 - Layui</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<script>
;!function(){self!==parent&&(location.href="https://www.baidu.com/")}();
</script>
<link rel="stylesheet" href="layui.css" media="all">
<link rel="stylesheet" href="global.css" media="all">
</head>
<body>
<style>
.site-dir{
z-index: 19891015;
position: fixed;
top: 513px;
left: 88%;
margin-left: -15px;
display: block;
box-shadow: none;
border: 1px solid #d2d2d2;
padding: 0.5%;
}
</style>
<div class="layui-header header header-doc">
<div class="layui-container">
<a class="logo" href="#" tppabs="https://www.layui.com/">
<img src="logo.png" tppabs="https://res.layui.com/static/images/layui/logo.png" alt="layui">
</a>
<div class="layui-form layui-hide-xs component" lay-filter="LAY-site-header-component"></div>
<div class="layui-hide-xs site-notice"></div>
<ul class="layui-nav" id="LAY_NAV_TOP">
<li class="layui-nav-item layui-this">
<a href="index.html" tppabs="https://www.layui.com/doc/">文档</a>
</li>
<li class="layui-nav-item ">
<a href="demo/index.htm" >示例</a>
</li>
</ul>
</div>
</div>
<!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
<!--[if lt IE 9]>
<script src="html5.min.js" tppabs="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
<script src="respond.min.js" tppabs="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<ul class="site-dir">
<div class="layui-layer-title" style="cursor: move;">目录</div>
<li><a href="#default"><cite>常规用法</cite></a></li>
<li><a href="#brief"><cite>Tab简约风格</cite></a></li>
<li><a href="#card"><cite>Tab卡片风格</cite></a></li>
<li><a href="#rwd"><cite>Tab响应式</cite></a></li>
<li><a href="#del"><cite>带删除的Tab</cite></a></li>
<li><a href="#layid"><cite>ID焦点定位</cite></a></li>
<li><a href="element-1.html" tppabs="https://www.layui.com/doc/modules/element.html"><cite>相关动态操作</cite></a></li>
</ul>
<div class="layui-container layui-row">
<div class="layui-col-md3">
<div class="layui-panel site-menu">
<ul class="layui-menu layui-menu-lg">
<li class="layui-menu-item-group" lay-options="{type: 'group', isAllowSpread: true}">
<div class="layui-menu-body-title">
基础说明
</div>
<hr>
<ul>
<li class="">
<div class="layui-menu-body-title">
<a href="index.html" tppabs="https://www.layui.com/doc/">
<span>开始使用 </span>
<span class="layui-font-12 layui-font-gray">Getting Started</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="infrastructure.html" tppabs="https://www.layui.com/doc/base/infrastructure.html">
<span>底层方法 </span>
<span class="layui-font-12 layui-font-gray">基础支撑</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="element.html" tppabs="https://www.layui.com/doc/base/element.html">
<span>页面元素 </span>
<span class="layui-font-12 layui-font-gray">规范 公共类 属性</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="modules.html" tppabs="https://www.layui.com/doc/base/modules.html">
<span>模块规范 </span>
<span class="layui-font-12 layui-font-gray">使用 扩展</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="faq.html" tppabs="https://www.layui.com/doc/base/faq.html">
<span>常见问题 </span>
<span class="layui-font-12 layui-font-gray">FAQ</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="changelog.html" tppabs="https://www.layui.com/doc/base/changelog.html">
<span>更新日志 </span>
<span class="layui-font-12 layui-font-gray">changelog</span>
<span class="layui-badge-dot"></span>
</a>
</div>
</li>
</ul>
</li>
<li class="layui-menu-item-group" lay-options="{type: 'group', isAllowSpread: true}">
<div class="layui-menu-body-title">
页面元素
</div>
<hr>
<ul>
<li class="">
<div class="layui-menu-body-title">
<a href="layout.html" tppabs="https://www.layui.com/doc/element/layout.html">
<span>布局 </span>
<span class="layui-font-12 layui-font-gray">栅格 后台管理布局</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="color.html" tppabs="https://www.layui.com/doc/element/color.html">
<span>颜色 </span>
<span class="layui-font-12 layui-font-gray">主色调 颜色搭配</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="icon.html" tppabs="https://www.layui.com/doc/element/icon.html">
<span>图标 </span>
<span class="layui-font-12 layui-font-gray">iconfont 字体图标</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="anim.html" tppabs="https://www.layui.com/doc/element/anim.html">
<span>动画 </span>
<span class="layui-font-12 layui-font-gray">内置 CSS3 动画</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="button.html" tppabs="https://www.layui.com/doc/element/button.html">
<span>按钮 </span>
<span class="layui-font-12 layui-font-gray">button</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="form.html" tppabs="https://www.layui.com/doc/element/form.html">
<span>表单 </span>
<span class="layui-font-12 layui-font-gray">form 元素集合</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="nav.html" tppabs="https://www.layui.com/doc/element/nav.html">
<span>导航 </span>
<span class="layui-font-12 layui-font-gray">nav 面包屑</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="menu.html" tppabs="https://www.layui.com/doc/element/menu.html">
<span>菜单 </span>
<span class="layui-font-12 layui-font-gray">menu 基础菜单</span>
<span class="layui-badge-dot"></span>
</a>
</div>
</li>
<li class="layui-menu-item-checked2">
<div class="layui-menu-body-title">
<a href="tab.html" tppabs="https://www.layui.com/doc/element/tab.html">
<span>选项卡 </span>
<span class="layui-font-12 layui-font-gray">Tabs 切换</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="progress.html" tppabs="https://www.layui.com/doc/element/progress.html">
<span>进度条 </span>
<span class="layui-font-12 layui-font-gray">progress</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="panel.html" tppabs="https://www.layui.com/doc/element/panel.html">
<span>面板 </span>
<span class="layui-font-12 layui-font-gray">panel 卡片 折叠</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="table.html" tppabs="https://www.layui.com/doc/element/table.html">
<span>表格 </span>
<span class="layui-font-12 layui-font-gray">静态 table</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="badge.html" tppabs="https://www.layui.com/doc/element/badge.html">
<span>徽章 </span>
<span class="layui-font-12 layui-font-gray">小圆点 小边框</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="timeline.html" tppabs="https://www.layui.com/doc/element/timeline.html">
<span>时间线 </span>
<span class="layui-font-12 layui-font-gray">timeline</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="auxiliar.html" tppabs="https://www.layui.com/doc/element/auxiliar.html">
<span>辅助 </span>
<span class="layui-font-12 layui-font-gray">引用 字段集 横线等</span>
</a>
</div>
</li>
</ul>
</li>
<li class="layui-menu-item-group" lay-options="{type: 'group', isAllowSpread: true}">
<div class="layui-menu-body-title">
内置模块
</div>
<hr>
<ul>
<li class="">
<div class="layui-menu-body-title">
<a href="layer.html" tppabs="https://www.layui.com/doc/modules/layer.html">
<span>弹出层 </span>
<span class="layui-font-12 layui-font-gray">layer</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="laydate.html" tppabs="https://www.layui.com/doc/modules/laydate.html">
<span>日期与时间选择 </span>
<span class="layui-font-12 layui-font-gray">laydate</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="laypage.html" tppabs="https://www.layui.com/doc/modules/laypage.html">
<span>分页 </span>
<span class="layui-font-12 layui-font-gray">laypage</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="laytpl.html" tppabs="https://www.layui.com/doc/modules/laytpl.html">
<span>模板引擎 </span>
<span class="layui-font-12 layui-font-gray">laytpl</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="table-1.html" tppabs="https://www.layui.com/doc/modules/table.html">
<span>数据表格 </span>
<span class="layui-font-12 layui-font-gray">table</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="form-1.html" tppabs="https://www.layui.com/doc/modules/form.html">
<span>表单 </span>
<span class="layui-font-12 layui-font-gray">form</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="upload.html" tppabs="https://www.layui.com/doc/modules/upload.html">
<span>文件上传 </span>
<span class="layui-font-12 layui-font-gray">upload</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="dropdown.html" tppabs="https://www.layui.com/doc/modules/dropdown.html">
<span>下拉菜单 </span>
<span class="layui-font-12 layui-font-gray">dropdown</span>
<span class="layui-badge-dot"></span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="transfer.html" tppabs="https://www.layui.com/doc/modules/transfer.html">
<span>穿梭框 </span>
<span class="layui-font-12 layui-font-gray">transfer</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="tree.html" tppabs="https://www.layui.com/doc/modules/tree.html">
<span>树形组件 </span>
<span class="layui-font-12 layui-font-gray">tree</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="colorpicker.html" tppabs="https://www.layui.com/doc/modules/colorpicker.html">
<span>颜色选择器 </span>
<span class="layui-font-12 layui-font-gray">colorpicker</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="element-1.html" tppabs="https://www.layui.com/doc/modules/element.html">
<span>常用元素操作 </span>
<span class="layui-font-12 layui-font-gray">element</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="slider.html" tppabs="https://www.layui.com/doc/modules/slider.html">
<span>滑块 </span>
<span class="layui-font-12 layui-font-gray">slider</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="rate.html" tppabs="https://www.layui.com/doc/modules/rate.html">
<span>评分 </span>
<span class="layui-font-12 layui-font-gray">rate</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="carousel.html" tppabs="https://www.layui.com/doc/modules/carousel.html">
<span>轮播 </span>
<span class="layui-font-12 layui-font-gray">carousel</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="flow.html" tppabs="https://www.layui.com/doc/modules/flow.html">
<span>流加载 </span>
<span class="layui-font-12 layui-font-gray">flow</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="util.html" tppabs="https://www.layui.com/doc/modules/util.html">
<span>工具组件 </span>
<span class="layui-font-12 layui-font-gray">util</span>
</a>
</div>
</li>
<li class="">
<div class="layui-menu-body-title">
<a href="code.html" tppabs="https://www.layui.com/doc/modules/code.html">
<span>代码高亮显示 </span>
<span class="layui-font-12 layui-font-gray">code</span>
</a>
</div>
</li>
</ul>
</li>
</ul>
</div>
<div class="layui-hide-v"> - </div>
</div>
<div class="layui-col-md9 site-content">
<h1 class="site-h1">Tab选项卡 - 页面元素</h1>
<blockquote class="site-text layui-elem-quote">
导航菜单可应用于头部和侧边,Tab选项卡提供多套风格,支持响应式,支持删除选项卡等功能。面包屑结构简单,支持自定义分隔符。
</blockquote>
<blockquote class="site-text layui-elem-quote">
依赖加载组件:<a href="element-1.html" tppabs="https://www.layui.com/doc/modules/element.html">element</a>
<span>(请注意:必须加载element模块,相关功能才能正常使用,详见:内置组件 - 常用元素操作)</span></blockquote>
<div class="site-title">
<fieldset><legend><a name="default">默认Tab选项卡</a></legend></fieldset>
</div>
<div class="site-text">
<p>
Tab广泛应用于Web页面,因此我们也对其进行了良好的支持。Layui内置多种Tab风格,支持删除选项卡、并提供响应式支持。
<br>这是一个最基本的例子:
</p>
<div class="layui-tab" style="margin: 30px 0;">
<ul class="layui-tab-title">
<li class="layui-this">网站设置</li>
<li>用户管理</li>
<li>权限分配</li>
<li>商品管理</li>
<li>订单管理</li>
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">
<blockquote class="layui-elem-quote">如果需要对Tab进行外部新增、删除、切换等操作,请移步到“内置组件-常用元素操作”页面中查阅:基础方法</blockquote>
</div>
<div class="layui-tab-item">内容2</div>
<div class="layui-tab-item">内容3</div>
<div class="layui-tab-item">内容4</div>
<div class="layui-tab-item">内容5</div>
</div>
</div>
<pre class="layui-code" lay-title="对应的HTML结构">
&lt;div class=&quot;layui-tab&quot;&gt;
&lt;ul class=&quot;layui-tab-title&quot;&gt;
&lt;li class=&quot;layui-this&quot;&gt;网站设置&lt;/li&gt;
&lt;li&gt;用户管理&lt;/li&gt;
&lt;li&gt;权限分配&lt;/li&gt;
&lt;li&gt;商品管理&lt;/li&gt;
&lt;li&gt;订单管理&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;layui-tab-content&quot;&gt;
&lt;div class=&quot;layui-tab-item layui-show&quot;&gt;内容1&lt;/div&gt;
&lt;div class=&quot;layui-tab-item&quot;&gt;内容2&lt;/div&gt;
&lt;div class=&quot;layui-tab-item&quot;&gt;内容3&lt;/div&gt;
&lt;div class=&quot;layui-tab-item&quot;&gt;内容4&lt;/div&gt;
&lt;div class=&quot;layui-tab-item&quot;&gt;内容5&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;script&gt;
//注意:选项卡 依赖 element 模块,否则无法进行功能性操作
layui.use('element', function(){
var element = layui.element;
//…
});
&lt;/script&gt;
</pre>
</div>
<div class="site-title">
<fieldset><legend><a name="brief">Tab简洁风格</a></legend></fieldset>
</div>
<div class="site-text">
<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief" style="margin: 0 0 20px;">
<ul class="layui-tab-title">
<li class="layui-this">网站设置</li>
<li>用户管理</li>
<li>权限分配</li>
<li>商品管理</li>
<li>订单管理</li>
</ul>
</div>
<pre class="layui-code" lay-title="对应的HTML结构">
&lt;div class=&quot;layui-tab layui-tab-brief&quot; lay-filter=&quot;docDemoTabBrief&quot;&gt;
&lt;ul class=&quot;layui-tab-title&quot;&gt;
&lt;li class=&quot;layui-this&quot;&gt;网站设置&lt;/li&gt;
&lt;li&gt;用户管理&lt;/li&gt;
&lt;li&gt;权限分配&lt;/li&gt;
&lt;li&gt;商品管理&lt;/li&gt;
&lt;li&gt;订单管理&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;layui-tab-content&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>通过追加class:<em>layui-tab-brief</em> 来设定简洁风格。<br>值得注意的是,如果存在 <em>layui-tab-item</em> 的内容区域,在切换时自动定位到对应内容。如果不存在内容区域,则不会定位到对应内容。你通常需要设置过滤器,通过 <em>element</em>模块的监听tab事件来进行切换操作。详见文档左侧【内置组件 - 基本元素操作 element】</p>
</div>
<div class="site-title">
<fieldset><legend><a name="card">Tab卡片风格</a></legend></fieldset>
</div>
<div class="site-text">
<div class="layui-tab layui-tab-card">
<ul class="layui-tab-title">
<li class="layui-this">网站设置</li>
<li>用户管理</li>
<li>权限分配</li>
<li>商品管理</li>
<li>订单管理</li>
</ul>
<div class="layui-tab-content" style="height: 100px;">
<div class="layui-tab-item layui-show">1</div>
<div class="layui-tab-item">2</div>
<div class="layui-tab-item">3</div>
<div class="layui-tab-item">4</div>
<div class="layui-tab-item">5</div>
<div class="layui-tab-item">6</div>
</div>
</div>
<pre class="layui-code" lay-title="对应的HTML结构">
&lt;div class=&quot;layui-tab layui-tab-card&quot;&gt;
&lt;ul class=&quot;layui-tab-title&quot;&gt;
&lt;li class=&quot;layui-this&quot;&gt;网站设置&lt;/li&gt;
&lt;li&gt;用户管理&lt;/li&gt;
&lt;li&gt;权限分配&lt;/li&gt;
&lt;li&gt;商品管理&lt;/li&gt;
&lt;li&gt;订单管理&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;layui-tab-content&quot; style=&quot;height: 100px;&quot;&gt;
&lt;div class=&quot;layui-tab-item layui-show&quot;&gt;1&lt;/div&gt;
&lt;div class=&quot;layui-tab-item&quot;&gt;2&lt;/div&gt;
&lt;div class=&quot;layui-tab-item&quot;&gt;3&lt;/div&gt;
&lt;div class=&quot;layui-tab-item&quot;&gt;4&lt;/div&gt;
&lt;div class=&quot;layui-tab-item&quot;&gt;5&lt;/div&gt;
&lt;div class=&quot;layui-tab-item&quot;&gt;6&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>通过追加class:<em>layui-tab-card</em>来设定卡片风格</p>
</div>
<div class="site-title">
<fieldset><legend><a name="rwd">Tab响应式</a></legend></fieldset>
</div>
<div class="site-text">
<p>当容器的宽度不足以显示全部的选项时,即会自动出现展开图标,如下以卡片风格为例(注意:所有Tab风格都支持响应式):</p>
<div style="text-align: center;">
<div class="layui-tab layui-tab-card layui-inline" style="margin-left: 20px; width: 363px;">
<ul class="layui-tab-title">
<li class="layui-this">网站设置</li>
<li>用户管理</li>
<li>权限分配</li>
<li>商品管理</li>
<li>订单管理</li>
</ul>
<div class="layui-tab-content" style="height: 100px;">
<div class="layui-tab-item layui-show">1</div>
<div class="layui-tab-item">2</div>
<div class="layui-tab-item">3</div>
<div class="layui-tab-item">4</div>
<div class="layui-tab-item">5</div>
<div class="layui-tab-item">6</div>
</div>
</div>
</div>
<p>额,感觉像是打了个小酱油。而事实上在自适应的页面中(不固宽),它的意义才会呈现。</p>
</div>
<div class="site-title">
<fieldset><legend><a name="del">带删除的Tab</a></legend></fieldset>
</div>
<div class="site-text">
<p>你可以对父层容器设置属性 <em>lay-allowClose="true"</em> 来允许Tab选项卡被删除</p>
<div class="layui-tab" lay-allowClose="true" style="margin: 20px 0;">
<ul class="layui-tab-title">
<li class="layui-this">网站设置</li>
<li>用户基本管理</li>
<li>权限分配</li>
<li>全部历史商品管理文字长一点试试</li>
<li>订单管理</li>
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">1</div>
<div class="layui-tab-item">2</div>
<div class="layui-tab-item">3</div>
<div class="layui-tab-item">4</div>
<div class="layui-tab-item">5</div>
<div class="layui-tab-item">6</div>
</div>
</div>
<pre class="layui-code" lay-title="对应的HTML结构">
&lt;div class=&quot;layui-tab&quot; lay-allowClose=&quot;true&quot;&gt;
&lt;ul class=&quot;layui-tab-title&quot;&gt;
&lt;li class=&quot;layui-this&quot;&gt;网站设置&lt;/li&gt;
&lt;li&gt;用户基本管理&lt;/li&gt;
&lt;li&gt;权限分配&lt;/li&gt;
&lt;li&gt;全部历史商品管理文字长一点试试&lt;/li&gt;
&lt;li&gt;订单管理&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;layui-tab-content&quot;&gt;
&lt;div class=&quot;layui-tab-item layui-show&quot;&gt;1&lt;/div&gt;
&lt;div class=&quot;layui-tab-item&quot;&gt;2&lt;/div&gt;
&lt;div class=&quot;layui-tab-item&quot;&gt;3&lt;/div&gt;
&lt;div class=&quot;layui-tab-item&quot;&gt;4&lt;/div&gt;
&lt;div class=&quot;layui-tab-item&quot;&gt;5&lt;/div&gt;
&lt;div class=&quot;layui-tab-item&quot;&gt;6&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>与默认相比没有什么特别的结构,就是多了个属性 <em>lay-allowClose="true"</em></p>
</div>
<div class="site-title">
<fieldset><legend><a name="layid">ID焦点定位</a></legend></fieldset>
</div>
<div class="site-text">
<p>你可以通过对选项卡设置属性 <em>lay-id="xxx"</em> 来作为唯一的匹配索引,以用于外部的定位切换,如后台的左侧导航、以及页面地址 hash的匹配。</p>
<pre class="layui-code" lay-title="对应的HTML结构">
&lt;div class=&quot;layui-tab&quot; lay-filter=&quot;test1&quot;&gt;
&lt;ul class=&quot;layui-tab-title&quot;&gt;
&lt;li class=&quot;layui-this&quot; <a>lay-id="111"</a> &gt;文章列表&lt;/li&gt;
&lt;li <a>lay-id="222"</a>&gt;发送信息&lt;/li&gt;
&lt;li <a>lay-id="333"</a>&gt;权限分配&lt;/li&gt;
&lt;li <a>lay-id="444"</a>&gt;审核&lt;/li&gt;
&lt;li <a>lay-id="555"</a>&gt;订单管理&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;layui-tab-content&quot;&gt;
&lt;div class=&quot;layui-tab-item layui-show&quot;&gt;1&lt;/div&gt;
&lt;div class=&quot;layui-tab-item&quot;&gt;2&lt;/div&gt;
&lt;div class=&quot;layui-tab-item&quot;&gt;3&lt;/div&gt;
&lt;div class=&quot;layui-tab-item&quot;&gt;4&lt;/div&gt;
&lt;div class=&quot;layui-tab-item&quot;&gt;5&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>属性 lay-id 是扮演这项功能的主要角色,它是动态操作的重要凭据,如:</p>
<pre class="layui-code">
&lt;script&gt;
layui.use('element', function(){
var element = layui.element;
//获取hash来切换选项卡,假设当前地址的hash为lay-id对应的值
var layid = location.hash.replace(/^#test1=/, '');
element.tabChange('test1', layid); //假设当前地址为:http://a.com#test1=222,那么选项卡会自动切换到“发送消息”这一项
//监听Tab切换,以改变地址hash值
element.on('tab(test1)', function(){
location.hash = 'test1='+ this.getAttribute('lay-id');
});
});
&lt;/script&gt;
</pre>
<p>同样的还有增加选项卡和删除选项卡,都需要用到 lay-id,更多动态操作请阅读:<a href="element-1.html" tppabs="https://www.layui.com/doc/modules/element.html">element模块</a></p>
</div>
<div class="site-title">
<fieldset><legend><a name="other">提示</a></legend></fieldset>
</div>
<div class="site-text">
<p>无论是导航、还是Tab,都需依赖 <em>element</em>模块,大部分行为都是在加载完该模块后自动完成的,但一些交互操作,如Tab事件监听等,需按照场景选择性使用。你可以移步文档左侧【内置组件 - 基本元素操作 element】了解详情 </p>
</div>
<div class="layui-elem-quote">
<p>layui - 在每一个细节中,用心与你沟通</p>
</div>
</div>
</div>
<div class="layui-footer footer footer-doc">
<p>致敬layui</p>
</div>
<script>
window.global = {
pageType: 'doc'
,preview: function(){
var preview = document.getElementById('LAY_preview');
return preview ? preview.innerHTML : '';
}()
};
</script>
<div class="site-tree-mobile layui-hide">
<i class="layui-icon layui-icon-spread-left"></i>
</div>
<div class="site-mobile-shade"></div>
<script src="https://cdn.bootcdn.net/ajax/libs/layui/2.6.8/layui.js"></script>
<script>
layui.use(['element', 'layer'], function(){
var element = layui.element
,layer = layui.layer;
element.on('tab(docDemoTabBrief)', function(data){
layer.msg('切到到了'+ data.index + '' + this.innerHTML);
});
});
</script>
</body>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
HTML
1
https://gitee.com/ceili/layui-official-website-static.git
git@gitee.com:ceili/layui-official-website-static.git
ceili
layui-official-website-static
layui官网静态
master

搜索帮助