-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdropdown-1.html
More file actions
982 lines (911 loc) · 29.9 KB
/
dropdown-1.html
File metadata and controls
982 lines (911 loc) · 29.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>通用下拉菜单 - 在线演示 - 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="http://www.baidu.com/")}();
</script>
<link rel="stylesheet" href="layui.css-t=1632659138211.css" tppabs="http://res.layui.com/layui/dist/css/layui.css?t=1632659138211" media="all">
<link rel="stylesheet" href="global.css-t=1632659138211-19.css" tppabs="http://res.layui.com/static/css/global.css?t=1632659138211-19" media="all">
</head>
<body>
<div class="layui-layout layui-layout-admin">
<div class="layui-header header header-demo">
<div class="layui-fluid">
<a class="logo" href="index.htm" tppabs="http://www.layui.com/">
<img src="logo.png" tppabs="http://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 ">
<a href="index-1.htm" tppabs="http://www.layui.com/doc/">文档</a>
</li>
<li class="layui-nav-item layui-this">
<a href="index-2.htm" tppabs="http://www.layui.com/demo/">示例</a>
</li>
<li class="layui-nav-item">
<a href="javascript:;">
<!--<span class="layui-badge-dot" style="left:0; right: auto; margin: -4px 0 0 5px;"></span>-->
周边
</a>
<dl class="layui-nav-child layui-nav-child-c">
<dd class="layui-hide-sm layui-show-xs" lay-unselect>
<a href="javascript:if(confirm(%27https://gitee.com/sentsin/layui/issues \n\nThis file was not retrieved by Teleport Pro, because it is addressed using an unsupported protocol (e.g., gopher). \n\nDo you want to open it from the server?%27))window.location=%27https://gitee.com/sentsin/layui/issues%27" tppabs="https://gitee.com/sentsin/layui/issues" target="_blank" rel="nofollow">问题反馈</a>
<hr>
</dd>
<dd lay-unselect><a href="alone.html" tppabs="http://www.layui.com/alone.html" target="_blank" lay-unselect>独立组件</a></dd>
<dd lay-unselect><a href="javascript:if(confirm(%27http://fly.layui.com/extend/ \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?%27))window.location=%27http://fly.layui.com/extend/%27" tppabs="http://fly.layui.com/extend/" target="_blank">扩展组件</a></dd>
</dl>
</li>
<li class="layui-nav-item layui-hide-xs">
<a href="javascript:if(confirm(%27http://gitee.com/sentsin/layui/issues \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?%27))window.location=%27http://gitee.com/sentsin/layui/issues%27" tppabs="http://gitee.com/sentsin/layui/issues" target="_blank" rel="nofollow">反馈</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]-->
<div class="layui-side layui-bg-black">
<div class="layui-side-scroll">
<ul class="layui-nav layui-nav-tree site-demo-nav">
<li class="layui-nav-item layui-nav-itemed">
<a class="javascript:;" href="javascript:;">演示</a>
<dl class="layui-nav-child">
<dd>
<a href="index-2.htm" tppabs="http://www.layui.com/demo/">调试预览</a>
</dd>
</dl>
</li>
<li class="layui-nav-item layui-nav-itemed">
<a class="javascript:;" href="javascript:;">布局</a>
<dl class="layui-nav-child">
<dd class="">
<a href="grid.html" tppabs="http://www.layui.com/demo/grid.html">栅格</a>
</dd>
<dd class="">
<a href="admin.html" tppabs="http://www.layui.com/demo/admin.html">框架</a>
</dd>
</dl>
</li>
<li class="layui-nav-item layui-nav-itemed">
<a class="javascript:;" href="javascript:;">基本元素</a>
<dl class="layui-nav-child">
<dd class="">
<a href="button-1.html" tppabs="http://www.layui.com/demo/button.html">按钮</a>
</dd>
<dd class="">
<a href="form-2.html" tppabs="http://www.layui.com/demo/form.html">表单</a>
</dd>
<dd class="">
<a href="nav-1.html" tppabs="http://www.layui.com/demo/nav.html">导航 / 面包屑</a>
</dd>
<dd class="">
<a href="menu-1.html" tppabs="http://www.layui.com/demo/menu.html">基础菜单</a>
</dd>
<dd class="">
<a href="tab-1.html" tppabs="http://www.layui.com/demo/tab.html">选项卡</a>
</dd>
<dd class="">
<a href="progress-1.html" tppabs="http://www.layui.com/demo/progress.html">进度条</a>
</dd>
<dd class="">
<a href="panel-1.html" tppabs="http://www.layui.com/demo/panel.html">面板</a>
</dd>
<dd class="">
<a href="badge-1.html" tppabs="http://www.layui.com/demo/badge.html">徽章</a>
</dd>
<dd class="">
<a href="timeline-1.html" tppabs="http://www.layui.com/demo/timeline.html">时间线</a>
</dd>
<dd class="">
<a href="table-element.html" tppabs="http://www.layui.com/demo/table-element.html">静态表格</a>
</dd>
<dd class="">
<a href="anim-1.html" tppabs="http://www.layui.com/demo/anim.html">动画</a>
</dd>
<dd class="">
<a href="auxiliar-1.html" tppabs="http://www.layui.com/demo/auxiliar.html">辅助元素</a>
</dd>
</dl>
</li>
<li class="layui-nav-item layui-nav-itemed">
<a class="javascript:;" href="javascript:;">组件示例</a>
<dl class="layui-nav-child">
<dd class="">
<a href="layer-1.html" tppabs="http://www.layui.com/demo/layer.html">
弹出层
</a>
</dd>
<dd class="">
<a href="laydate-1.html" tppabs="http://www.layui.com/demo/laydate.html">
日期与时间选择
</a>
</dd>
<dd class="">
<a href="table-2.html" tppabs="http://www.layui.com/demo/table.html">
数据表格
</a>
</dd>
<dd class="">
<a href="laypage-1.html" tppabs="http://www.layui.com/demo/laypage.html">
分页
</a>
</dd>
<dd class="layui-this">
<a href="dropdown-1.html" tppabs="http://www.layui.com/demo/dropdown.html">
下拉菜单
</a>
</dd>
<dd class="">
<a href="upload-1.html" tppabs="http://www.layui.com/demo/upload.html">
文件上传
</a>
</dd>
<dd class="">
<a href="transfer-1.html" tppabs="http://www.layui.com/demo/transfer.html">
穿梭框
</a>
</dd>
<dd class="">
<a href="tree-1.html" tppabs="http://www.layui.com/demo/tree.html">
树形组件
</a>
</dd>
<dd class="">
<a href="colorpicker-1.html" tppabs="http://www.layui.com/demo/colorpicker.html">
颜色选择器
</a>
</dd>
<dd class="">
<a href="slider-1.html" tppabs="http://www.layui.com/demo/slider.html">
滑块
</a>
</dd>
<dd class="">
<a href="rate-1.html" tppabs="http://www.layui.com/demo/rate.html">
评分
</a>
</dd>
<dd class="">
<a href="carousel-1.html" tppabs="http://www.layui.com/demo/carousel.html">
轮播
</a>
</dd>
<dd class="">
<a href="laytpl-1.html" tppabs="http://www.layui.com/demo/laytpl.html">
模板引擎
</a>
</dd>
<dd class="">
<a href="flow-1.html" tppabs="http://www.layui.com/demo/flow.html">
流加载
</a>
</dd>
<dd class="">
<a href="util-1.html" tppabs="http://www.layui.com/demo/util.html">
工具模块
</a>
</dd>
<dd class="">
<a href="code-1.html" tppabs="http://www.layui.com/demo/code.html">
文本行修饰
</a>
</dd>
</dl>
</li>
<li class="layui-nav-item" style="height: 30px; text-align: center"></li>
</ul>
</div>
</div>
<div class="layui-tab layui-tab-brief" lay-filter="demoTitle">
<ul class="layui-tab-title site-demo-title">
<li class="layui-this">预览</li>
<li>查看代码</li>
<li>帮助</li>
</ul>
<div class="layui-body layui-tab-content site-demo site-demo-body">
<div class="layui-tab-item layui-show">
<div class="layui-main">
<div id="LAY_preview">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
<legend>初演示</legend>
</fieldset>
<div class="layui-btn-container">
<button class="layui-btn demo1">
下拉菜单
<i class="layui-icon layui-icon-down layui-font-12"></i>
</button>
<button class="layui-btn layui-btn-primary demo1">
下拉菜单
<i class="layui-icon layui-icon-down layui-font-12"></i>
</button>
</div>
<div class="layui-inline" style="width: 235px;">
<input name="" placeholder="在输入框提供一些常用的选项" class="layui-input" id="demo2">
</div>
<div class="layui-inline layui-word-aux layui-font-gray">
可以绑定任意元素,<a href="javascript:;" class="layui-font-blue" id="demo3">比如这段文字 <i class="layui-icon layui-font-12 layui-icon-down"></i></a>
</div>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
<legend>高级演示</legend>
</fieldset>
<div class="layui-btn-container">
<button class="layui-btn" id="demo100">
无限层级 + 跳转 + 事件 + 自定义模板
</button>
</div>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
<legend>在表格中的应用</legend>
</fieldset>
<div style="max-width: 728px;">
<table class="layui-hide" id="test-dropdown-table" lay-filter="test-dropdown-table"></table>
</div>
<script type="text/html" id="test-dropdown-toolbar-barDemo">
<a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-xs" lay-event="more">更多 <i class="layui-icon layui-icon-down"></i></a>
</script>
<div style="margin-top: 15px">
<!-- 示例-970 -->
<!--
<ins class="adsbygoogle"
style="display:inline-block;width:970px;height:90px"
data-ad-client="ca-pub-6111334333458862"
data-ad-slot="3820120620"></ins>
-->
</div>
<fieldset class="layui-elem-field layui-field-title">
<legend>自定义事件</legend>
</fieldset>
<div class="layui-btn-container">
<button class="layui-btn layui-btn-primary" id="demo4">
hover
<i class="layui-icon layui-icon-more-vertical layui-font-12"></i>
</button>
<button class="layui-btn layui-btn-primary" id="demo5">
mousedown
<i class="layui-icon layui-icon-down layui-font-12"></i>
</button>
<button class="layui-btn layui-btn-primary" id="demo6">
dblclick - 双击
<i class="layui-icon layui-icon-circle layui-font-12"></i>
</button>
</div>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
<legend>右键菜单</legend>
</fieldset>
<div class="layui-bg-gray" style="height: 260px; text-align: center;" id="demo7">
<span class="layui-font-gray" style="position: relative; top:50%;">在此区域单击鼠标右键</span>
</div>
<button class="layui-btn" style="margin-top: 15px;" lay-demoActive="rightclick">
开启全局右键菜单
</button>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
<legend>弹出位置</legend>
</fieldset>
<div class="layui-btn-container">
<button class="layui-btn layui-btn-primary" id="demo200">
左对齐
<i class="layui-icon layui-icon-down layui-font-12"></i>
</button>
<button class="layui-btn layui-btn-primary" id="demo201">
居中对齐
<i class="layui-icon layui-icon-down layui-font-12"></i>
</button>
<button class="layui-btn layui-btn-primary" id="demo202">
右对齐
<i class="layui-icon layui-icon-down layui-font-12"></i>
</button>
</div>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
<legend>重定义风格</legend>
</fieldset>
<div class="layui-btn-container">
<button class="layui-btn" id="demo8">
重定义样式
<i class="layui-icon layui-icon-list layui-font-14"></i>
</button>
<style>
.site-dropdown-demo,
.site-dropdown-demo .layui-menu{background-color: #000; border: none;}
.site-dropdown-demo .layui-menu li{color: #fff;}
.site-dropdown-demo .layui-menu li:hover{background-color: #333;}
</style>
<button class="layui-btn" id="demo9">
重定义内容
<i class="layui-icon layui-icon-list layui-font-14"></i>
</button>
</div>
</div>
<blockquote class="layui-elem-quote" style="margin-top: 30px;">
更多我们未能呈现的示例,还有待您在阅读文档、以及不断使用的过程,去深入挖掘。
</blockquote>
<div style="margin: 15px 0 100px; padding-bottom: 100px;">
<!-- 通用-970*90 -->
<ins class="adsbygoogle"
style="display:inline-block;width:970px;height:90px"
data-ad-client="ca-pub-6111334333458862"
data-ad-slot="6835627838"></ins>
</div>
</div>
</div>
<div class="layui-tab-item">
<textarea class="layui-border-box site-demo-text site-demo-code" id="LAY_democode" spellcheck="false" readonly>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>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">
<link rel="stylesheet" href="layui.css" tppabs="http://res.layui.com/layui/dist/css/layui.css" media="all">
<!-- 注意:如果你直接复制所有代码到本地,上述css路径需要改成你本地的 -->
</head>
</textarea>
</div>
<div class="layui-tab-item">
<div class="layui-main">
<p></p>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
<legend>相关</legend>
</fieldset>
<a class="layui-btn layui-btn-normal" href="dropdown.html" tppabs="http://www.layui.com/doc/modules/dropdown.html" target="_blank">下拉菜单文档</a>
</div>
</div>
</div>
</div>
<div class="layui-footer footer footer-demo">
<p>
Copyright © 2021 <a href="index.htm" tppabs="http://www.layui.com/">layui.com</a> MIT Licensed</p>
<p>
<a href="disclaimer.html" tppabs="http://www.layui.com/about/disclaimer.html" target="_blank">免责声明</a>
<a href="relatedlinks.html" tppabs="http://www.layui.com/about/relatedlinks.html" target="_blank">友链</a>
<a href="javascript:;" site-event="weixinmp">公众号</a>
<a target="_blank" href="javascript:if(confirm(%27http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=36010902000274 \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?%27))window.location=%27http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=36010902000274%27" tppabs="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=36010902000274" rel="nofollow">
<img src="168_1628847893037_87773.png" tppabs="http://cdn.layui.com/upload/2021_8/168_1628847893037_87773.png">
赣公网安备 36010902000274号
</a>
<a href="javascript:if(confirm(%27https://beian.miit.gov.cn/ \n\nThis file was not retrieved by Teleport Pro, because it is addressed using an unsupported protocol (e.g., gopher). \n\nDo you want to open it from the server?%27))window.location=%27https://beian.miit.gov.cn/%27" tppabs="https://beian.miit.gov.cn/" target="_blank" rel="nofollow">赣ICP备13006272号</a>
</p>
<div class="site-union">
<p class="site-union-desc">
<span>
</span>
</p>
<p>
<a href="javascript:if(confirm(%27https://console.upyun.com/register/?invite=SJ0wu6g2- \n\nThis file was not retrieved by Teleport Pro, because it is addressed using an unsupported protocol (e.g., gopher). \n\nDo you want to open it from the server?%27))window.location=%27https://console.upyun.com/register/?invite=SJ0wu6g2-%27" tppabs="https://console.upyun.com/register/?invite=SJ0wu6g2-" target="_blank" rel="nofollow" sponsor="upyun">
<img src="upyun.png-t=1.png" tppabs="http://res.layui.com/static/images/other/upyun.png?t=1" alt="upyun">
</a>
<a href="javascript:if(confirm(%27https://www.maoyun.com/?from=layui \n\nThis file was not retrieved by Teleport Pro, because it is addressed using an unsupported protocol (e.g., gopher). \n\nDo you want to open it from the server?%27))window.location=%27https://www.maoyun.com/?from=layui%27" tppabs="https://www.maoyun.com/?from=layui" target="_blank" rel="nofollow" sponsor="maoyun">
<img src="168_1559291577683_9348.png" tppabs="http://cdn.layui.com/upload/2019_5/168_1559291577683_9348.png" alt="maoyun">
</a>
</p>
</div>
</div>
<script>
window.global = {
pageType: 'demo'
,preview: function(){
var preview = document.getElementById('LAY_preview');
return preview ? preview.innerHTML : '';
}()
};
</script>
<script async src="adsbygoogle.js" tppabs="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></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="layui.js-t=1632659138211.js" tppabs="http://res.layui.com/layui/dist/layui.js?t=1632659138211" charset="utf-8"></script>
<script>
layui.config({
base: '//res.layui.com/static/lay/modules/layui/'
,version: '1632659138211'
}).use('global');
</script>
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "hm.js-d214947968792b839fd669a4decaaffc"/*tpa=https://hm.baidu.com/hm.js?d214947968792b839fd669a4decaaffc*/;
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</div>
<div id="LAY_democodejs">
<script>
layui.use(['dropdown', 'util', 'layer', 'table'], function(){
var dropdown = layui.dropdown
,util = layui.util
,layer = layui.layer
,table = layui.table
,$ = layui.jquery;
//初演示
dropdown.render({
elem: '.demo1'
,data: [{
title: 'menu item11'
,id: 100
},{
title: 'menu item22'
,id: 101
},{
title: 'menu item33'
,id: 102
}]
,click: function(obj){
layer.tips('点击了:'+ obj.title, this.elem, {tips: [1, '#5FB878']})
}
});
//初演示 - 绑定输入框
dropdown.render({
elem: '#demo2'
,data: [{
title: 'menu item 1'
,id: 101
},{
title: 'menu item 2'
,id: 102
},{
title: 'menu item 3'
,id: 103
},{
title: 'menu item 4'
,id: 104
},{
title: 'menu item 5'
,id: 105
},{
title: 'menu item 6'
,id: 106
}]
,click: function(obj){
this.elem.val(obj.title);
}
,style: 'width: 235px;'
});
//初演示 - 绑定文字
dropdown.render({
elem: '#demo3'
,data: [{
title: 'menu item 1'
,id: 100
},{
title: 'menu item 2'
,id: 101
,child: [{ //横向子菜单
title: 'menu item 2-1'
,id: 1011
},{
title: 'menu item 2-2'
,id: 1012
}]
},{
title: 'menu item 3'
,id: 102
},{
type: '-' //分割线
},{
title: 'menu group'
,id: 103
,type: 'group' //纵向菜单组
,child: [{
title: 'menu item 4-1'
,id: 1031
},{
title: 'menu item 4-2'
,id: 1032
}]
},{
type: '-' //分割线
},{
title: 'menu item 5'
,id: 104
},{
title: 'menu item 5'
,id: 104
}]
,click: function(obj){
this.elem.val(obj.title);
}
});
//高级演示 - 各种组合
dropdown.render({
elem: '#demo100'
,data: [{
title: 'menu item 1'
,templet: '<i class="layui-icon layui-icon-picture"></i> {{d.title}} <span class="layui-badge-dot"></span>'
,id: 100
,href: '#'
},{
title: 'menu item 2'
,templet: '<img src="http://cdn.layui.com/avatar/168.jpg?t=123" style="width: 16px;"> {{d.title}}'
,id: 101
,href: '/'
,target: '_blank'
}
,{type: '-'} //分割线
,{
title: 'menu item 3'
,id: 102
,type: 'group'
,child: [{
title: 'menu item 3-1'
,id: 103
},{
title: 'menu item 3-2'
,id: 104
,child: [{
title: 'menu item 3-2-1'
,id: 105
},{
title: 'menu item 3-2-2'
,id: 11
,type: 'group'
,child: [{
title: 'menu item 3-2-2-1'
,id: 111
},{
title: 'menu item 3-2-2-2'
,id: 1111
}]
},{
title: 'menu item 3-2-3'
,id: 11111
}]
},{
title: 'menu item 3-3'
,id: 111111
,type: 'group'
,child: [{
title: 'menu item 3-3-1'
,id: 22
},{
title: 'menu item 3-3-2'
,id: 222
,child: [{
title: 'menu item 3-3-2-1'
,id: 2222
},{
title: 'menu item 3-3-2-2'
,id: 22222
},{
title: 'menu item 3-3-2-3'
,id: 2222222
}]
},{
title: 'menu item 3-3-3'
,id: 333
}]
}]
}
,{type: '-'}
,{
title: 'menu item 4'
,id: 4
},{
title: 'menu item 5'
,id: 5
,child: [{
title: 'menu item 5-1'
,id: 55
,child: [{
title: 'menu item 5-1-1'
,id: 5555
},{
title: 'menu item 5-1-2'
,id: 55555
},{
title: 'menu item 5-1-3'
,id: 555555
}]
},{
title: 'menu item 5-2'
,id: 52
},{
title: 'menu item 5-3'
,id: 53
}]
},{type:'-'},{
title: 'menu item 6'
,id: 66
,type: 'group'
,isSpreadItem: false
,child: [{
title: 'menu item 6-1'
,id: 666
},{
title: 'menu item 6-2'
,id: 6666
},{
title: 'menu item 6-3'
,id: 66666
}]
}]
,click: function(item){
layer.msg(util.escape(JSON.stringify(item)));
}
});
// dropdown 在表格中的应用
table.render({
elem: '#test-dropdown-table'
,url: 'demo5.json.js'/*tpa=http://www.layui.com/test/table/demo5.json*/
,title: '用户数据表'
,cols: [[
{type: 'checkbox', fixed: 'left'}
,{field:'id', title:'ID', width:80, fixed: 'left', unresize: true, sort: true}
,{field:'username', title:'用户名', width:120, edit: 'text'}
,{field:'email', title:'邮箱', minWidth:150}
,{fixed: 'right', title:'操作', toolbar: '#test-dropdown-toolbar-barDemo', width:150}
]]
,limits: [3]
,page: true
});
//行工具事件
table.on('tool(test-dropdown-table)', function(obj){
var that = this
,data = obj.data;
if(obj.event === 'edit'){
layer.prompt({
formType: 2
,value: data.email
}, function(value, index){
obj.update({
email: value
});
layer.close(index);
});
} else if(obj.event === 'more'){
//更多下拉菜单
dropdown.render({
elem: that
,show: true //外部事件触发即显示
,data: [{
title: 'item 1'
,id: 'aaa'
}, {
title: 'item 2'
,id: 'bbb'
}, {
title: '删除'
,id: 'del'
}]
,click: function(data, othis){
//根据 id 做出不同操作
if(data.id === 'del'){
layer.confirm('真的删除行么', function(index){
obj.del();
layer.close(index);
});
} else {
layer.msg('得到表格下拉菜单 id:'+ data.id);
}
}
,align: 'right' //右对齐弹出(v2.6.8 新增)
,style: 'box-shadow: 1px 1px 10px rgb(0 0 0 / 12%);' //设置额外样式
});
}
});
//自定义事件 - hover
dropdown.render({
elem: '#demo4'
,trigger: 'hover'
,data: [{
title: 'menu item 1'
,id: 100
},{
title: 'menu item 2'
,id: 101
},{
title: 'menu item 3'
,id: 102
}]
});
//自定义事件 - mousedown
dropdown.render({
elem: '#demo5'
,trigger: 'mousedown'
,data: [{
title: 'menu item 1'
,id: 100
},{
title: 'menu item 2'
,id: 101
},{
title: 'menu item 3'
,id: 102
}]
});
//自定义事件 - dblclick
dropdown.render({
elem: '#demo6'
,trigger: 'dblclick'
,data: [{
title: 'menu item 1'
,id: 100
},{
title: 'menu item 2'
,id: 101
},{
title: 'menu item 3'
,id: 102
}]
});
//右键菜单
var inst = dropdown.render({
elem: '#demo7' //也可绑定到 document,从而重置整个右键
,trigger: 'contextmenu' //contextmenu
,isAllowSpread: false //禁止菜单组展开收缩
,style: 'width: 200px' //定义宽度,默认自适应
,id: 'test777' //定义唯一索引
,data: [{
title: 'menu item 1'
,id: 'test'
}, {
title: 'Printing'
,id: 'print'
},{
title: 'Reload'
,id: 'reload'
},{type:'-'},{
title: 'menu item 3'
,id: '#3'
,child: [{
title: 'menu item 3-1'
,id: '#1'
},{
title: 'menu item 3-2'
,id: '#2'
},{
title: 'menu item 3-3'
,id: '#3'
}]
},{type:'-'},{
title: 'menu item 4'
,id: ''
},{
title: 'menu item 5'
,id: '#1'
},{
title: 'menu item 6'
,id: '#1'
}]
,click: function(obj, othis){
if(obj.id === 'test'){
layer.msg('click');
} else if(obj.id === 'print'){
window.print();
} else if(obj.id === 'reload'){
location.reload();
}
}
});
//对齐方式
dropdown.render({
elem: '#demo200'
,data: [{
title: 'menu item test 111'
,id: 100
},{
title: 'menu item test 222'
,id: 101
},{
title: 'menu item test 333'
,id: 102
}]
});
dropdown.render({
elem: '#demo201'
,align: 'center' //居中对齐(2.6.8 新增)
,data: [{
title: 'menu item test 111'
,id: 100
},{
title: 'menu item test 222'
,id: 101
},{
title: 'menu item test 333'
,id: 102
}]
});
dropdown.render({
elem: '#demo202'
,align: 'right' //右对齐(2.6.8 新增)
,data: [{
title: 'menu item test 111'
,id: 100
},{
title: 'menu item test 222'
,id: 101
},{
title: 'menu item test 333'
,id: 102
}]
});
//重定义样式
dropdown.render({
elem: '#demo8'
,data: [{
title: 'menu item 1'
,id: 100
},{
title: 'menu item 2'
,id: 101
},{
title: 'menu item 3'
,id: 103
},{
title: 'menu item 4'
,id: 104
},{
title: 'menu item 5'
,id: 105
},{
title: 'menu item 6'
,id: 106
}]
,className: 'site-dropdown-demo'
,ready: function(elemPanel, elem){
layer.msg('定义了一个 className');
}
});
//重定义内容
dropdown.render({
elem: '#demo9'
,content: ['<div class="layui-tab layui-tab-brief">'
,'<ul class="layui-tab-title">'
,'<li class="layui-this">Tab header 1</li>'
,'<li>Tab header 2</li>'
,'<li>Tab header 3</li>'
,'</ul>'
,'<div class="layui-tab-content">'
,'<div class="layui-tab-item layui-text layui-show"><p style="padding-bottom: 10px;">在 content 参数中插入任意的 html 内容,可替代默认的下拉菜单。 从而实现更多有趣的弹出内容。</p><p> 是否发现,dropdown 组件不仅仅只是一个下拉菜单或者右键菜单,它能被赋予许多的想象可能。</p></div>'
,'<div class="layui-tab-item">Tab body 2</div>'
,'<div class="layui-tab-item">Tab body 3</div>'
,'</div>'
,'</div>'].join('')
,style: 'width: 370px; height: 200px; padding: 0 15px; box-shadow: 1px 1px 30px rgb(0 0 0 / 12%);'
,ready: function(){
layui.use('element', function(element){
element.render('tab');
});
}
});
//其他操作
util.event('lay-demoactive', {
//全局右键菜单
rightclick: function(othis){
if(!othis.data('open')){
dropdown.reload('test777', {
elem: document //将事件直接绑定到 document
});
layer.msg('已开启全局右键菜单,请尝试在页面任意处单击右键。')
othis.html('取消全局右键菜单');
othis.data('open', true);
} else {
dropdown.reload('test777', {
elem: '#demo7' //重新绑定到指定元素上
});
layer.msg('已取消全局右键菜单,恢复默认右键菜单')
othis.html('开启全局右键菜单');
othis.data('open', false);
}
}
})
});
</script>
</div>
</body>
</html>