transfer.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>镜像站@ 穿梭框- 在线演示 - Layui</title>
  6. <meta name="renderer" content="webkit">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  8. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  9. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  10. <meta name="apple-mobile-web-app-capable" content="yes">
  11. <meta name="format-detection" content="telephone=no">
  12. <script>
  13. ;!function(){self!==parent&&(location.href="http://www.baidu.com/")}();
  14. </script>
  15. <link rel="stylesheet" href="/public/layui/dist/css/layui.css" tppabs="http://res.layui.com/layui/dist/css/layui.css?t=1632428048260" media="all">
  16. <link rel="stylesheet" href="/public/static/css/global.css" tppabs="http://res.layui.com/static/css/global.css?t=1632428048260-19" media="all">
  17. <style>
  18. .demo-transfer{margin: 10px 30px;}
  19. </style>
  20. </head>
  21. <body>
  22. <div class="layui-layout layui-layout-admin">
  23. <div class="layui-header header header-demo" autumn>
  24. <div class="layui-fluid">
  25. <a class="logo" href="../index.html" tppabs="http://www.layui.com/">
  26. <img src="/public/static/images/layui/logo.png" tppabs="http://res.layui.com/static/images/layui/logo.png" alt="layui">
  27. </a>
  28. <div class="layui-form layui-hide-xs component" lay-filter="LAY-site-header-component"></div>
  29. <div class="layui-hide-xs site-notice"></div>
  30. <ul class="layui-nav" id="LAY_NAV_TOP">
  31. <li class="layui-nav-item ">
  32. <a href="../doc/index.html" tppabs="http://www.layui.com/doc/">文档</a>
  33. </li>
  34. <li class="layui-nav-item layui-this">
  35. <a href="index.html" tppabs="http://www.layui.com/demo/">示例</a>
  36. </li>
  37. <li class="layui-nav-item">
  38. <a href="javascript:;">
  39. <!--<span class="layui-badge-dot" style="left:0; right: auto; margin: -4px 0 0 5px;"></span>-->
  40. 周边
  41. </a>
  42. <dl class="layui-nav-child layui-nav-child-c">
  43. <dd class="layui-hide-sm layui-show-xs" lay-unselect>
  44. <a href="https://gitee.com/sentsin/layui/issues" target="_blank" rel="nofollow">问题反馈</a>
  45. <hr>
  46. </dd>
  47. <dd lay-unselect><a href="../alone.html" tppabs="http://www.layui.com/alone.html" target="_blank" lay-unselect>独立组件</a></dd>
  48. <dd lay-unselect><a href="../../fly.layui.com/extend/index.html" target="_blank">扩展组件</a></dd>
  49. </dl>
  50. </li>
  51. <li class="layui-nav-item layui-hide-xs">
  52. <a href="http://gitee.com/sentsin/layui/issues" target="_blank" rel="nofollow">反馈</a>
  53. </li>
  54. </ul>
  55. </div>
  56. </div>
  57. <!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
  58. <!--[if lt IE 9]>
  59. <script src="../../other/html5shiv/r29/html5.min.js" tppabs="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  60. <script src="../../other/respond.js/1.4.2/respond.min.js" tppabs="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  61. <![endif]-->
  62. <div class="layui-side layui-bg-black">
  63. <div class="layui-side-scroll">
  64. <ul class="layui-nav layui-nav-tree site-demo-nav">
  65. <li class="layui-nav-item layui-nav-itemed">
  66. <a class="javascript:;" href="javascript:;">演示</a>
  67. <dl class="layui-nav-child">
  68. <dd>
  69. <a href="index.html" tppabs="http://www.layui.com/demo/">调试预览</a>
  70. </dd>
  71. </dl>
  72. </li>
  73. <li class="layui-nav-item layui-nav-itemed">
  74. <a class="javascript:;" href="javascript:;">布局</a>
  75. <dl class="layui-nav-child">
  76. <dd class="">
  77. <a href="grid.html" tppabs="http://www.layui.com/demo/grid.html">栅格</a>
  78. </dd>
  79. <dd class="">
  80. <a href="admin.html" tppabs="http://www.layui.com/demo/admin.html">框架</a>
  81. </dd>
  82. </dl>
  83. </li>
  84. <li class="layui-nav-item layui-nav-itemed">
  85. <a class="javascript:;" href="javascript:;">基本元素</a>
  86. <dl class="layui-nav-child">
  87. <dd class="">
  88. <a href="button.html" tppabs="http://www.layui.com/demo/button.html">按钮</a>
  89. </dd>
  90. <dd class="">
  91. <a href="form.html" tppabs="http://www.layui.com/demo/form.html">表单</a>
  92. </dd>
  93. <dd class="">
  94. <a href="nav.html" tppabs="http://www.layui.com/demo/nav.html">导航 / 面包屑</a>
  95. </dd>
  96. <dd class="">
  97. <a href="menu.html" tppabs="http://www.layui.com/demo/menu.html">基础菜单</a>
  98. </dd>
  99. <dd class="">
  100. <a href="tab.html" tppabs="http://www.layui.com/demo/tab.html">选项卡</a>
  101. </dd>
  102. <dd class="">
  103. <a href="progress.html" tppabs="http://www.layui.com/demo/progress.html">进度条</a>
  104. </dd>
  105. <dd class="">
  106. <a href="panel.html" tppabs="http://www.layui.com/demo/panel.html">面板</a>
  107. </dd>
  108. <dd class="">
  109. <a href="badge.html" tppabs="http://www.layui.com/demo/badge.html">徽章</a>
  110. </dd>
  111. <dd class="">
  112. <a href="timeline.html" tppabs="http://www.layui.com/demo/timeline.html">时间线</a>
  113. </dd>
  114. <dd class="">
  115. <a href="table-element.html" tppabs="http://www.layui.com/demo/table-element.html">静态表格</a>
  116. </dd>
  117. <dd class="">
  118. <a href="anim.html" tppabs="http://www.layui.com/demo/anim.html">动画</a>
  119. </dd>
  120. <dd class="">
  121. <a href="auxiliar.html" tppabs="http://www.layui.com/demo/auxiliar.html">辅助元素</a>
  122. </dd>
  123. </dl>
  124. </li>
  125. <li class="layui-nav-item layui-nav-itemed">
  126. <a class="javascript:;" href="javascript:;">组件示例</a>
  127. <dl class="layui-nav-child">
  128. <dd class="">
  129. <a href="layer.html" tppabs="http://www.layui.com/demo/layer.html">
  130. 弹出层
  131. </a>
  132. </dd>
  133. <dd class="">
  134. <a href="laydate.html" tppabs="http://www.layui.com/demo/laydate.html">
  135. 日期与时间选择
  136. </a>
  137. </dd>
  138. <dd class="">
  139. <a href="table.html" tppabs="http://www.layui.com/demo/table.html">
  140. 数据表格
  141. </a>
  142. </dd>
  143. <dd class="">
  144. <a href="laypage.html" tppabs="http://www.layui.com/demo/laypage.html">
  145. 分页
  146. </a>
  147. </dd>
  148. <dd class="">
  149. <a href="dropdown.html" tppabs="http://www.layui.com/demo/dropdown.html">
  150. 下拉菜单
  151. </a>
  152. </dd>
  153. <dd class="">
  154. <a href="upload.html" tppabs="http://www.layui.com/demo/upload.html">
  155. 文件上传
  156. </a>
  157. </dd>
  158. <dd class="layui-this">
  159. <a href="transfer.html" tppabs="http://www.layui.com/demo/transfer.html">
  160. 穿梭框
  161. </a>
  162. </dd>
  163. <dd class="">
  164. <a href="tree.html" tppabs="http://www.layui.com/demo/tree.html">
  165. 树形组件
  166. </a>
  167. </dd>
  168. <dd class="">
  169. <a href="colorpicker.html" tppabs="http://www.layui.com/demo/colorpicker.html">
  170. 颜色选择器
  171. </a>
  172. </dd>
  173. <dd class="">
  174. <a href="slider.html" tppabs="http://www.layui.com/demo/slider.html">
  175. 滑块
  176. </a>
  177. </dd>
  178. <dd class="">
  179. <a href="rate.html" tppabs="http://www.layui.com/demo/rate.html">
  180. 评分
  181. </a>
  182. </dd>
  183. <dd class="">
  184. <a href="carousel.html" tppabs="http://www.layui.com/demo/carousel.html">
  185. 轮播
  186. </a>
  187. </dd>
  188. <dd class="">
  189. <a href="laytpl.html" tppabs="http://www.layui.com/demo/laytpl.html">
  190. 模板引擎
  191. </a>
  192. </dd>
  193. <dd class="">
  194. <a href="layedit.html" tppabs="http://www.layui.com/demo/layedit.html">
  195. 富文本编辑器
  196. </a>
  197. </dd>
  198. <dd class="">
  199. <a href="flow.html" tppabs="http://www.layui.com/demo/flow.html">
  200. 流加载
  201. </a>
  202. </dd>
  203. <dd class="">
  204. <a href="util.html" tppabs="http://www.layui.com/demo/util.html">
  205. 工具模块
  206. </a>
  207. </dd>
  208. <dd class="">
  209. <a href="code.html" tppabs="http://www.layui.com/demo/code.html">
  210. 文本行修饰
  211. </a>
  212. </dd>
  213. </dl>
  214. </li>
  215. <li class="layui-nav-item" style="height: 30px; text-align: center"></li>
  216. </ul>
  217. </div>
  218. </div>
  219. <div class="layui-tab layui-tab-brief" lay-filter="demoTitle">
  220. <ul class="layui-tab-title site-demo-title">
  221. <li class="layui-this">预览</li>
  222. <li>查看代码</li>
  223. <li>帮助</li>
  224. </ul>
  225. <div class="layui-body layui-tab-content site-demo site-demo-body">
  226. <div class="layui-tab-item layui-show">
  227. <div class="layui-main">
  228. <div id="LAY_preview">
  229. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  230. <legend>基础效果</legend>
  231. </fieldset>
  232. <div id="test1" class="demo-transfer"></div>
  233. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  234. <legend>定义标题及数据源</legend>
  235. </fieldset>
  236. <div id="test2" class="demo-transfer"></div>
  237. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  238. <legend>初始右侧数据集合</legend>
  239. </fieldset>
  240. <div id="test3" class="demo-transfer"></div>
  241. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  242. <legend>显示搜索框</legend>
  243. </fieldset>
  244. <div id="test4" class="demo-transfer"></div>
  245. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  246. <legend>数据格式解析</legend>
  247. </fieldset>
  248. <div id="test5" class="demo-transfer"></div>
  249. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  250. <legend>穿梭时的回调</legend>
  251. </fieldset>
  252. <div id="test6" class="demo-transfer"></div>
  253. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
  254. <legend>实例调用</legend>
  255. </fieldset>
  256. <div class="layui-btn-container">
  257. <button type="button" class="layui-btn" lay-demoTransferActive="getData">获取右侧数据</button>
  258. <button type="button" class="layui-btn" lay-demoTransferActive="reload">重载实例</button>
  259. </div>
  260. <div id="test7" class="demo-transfer"></div>
  261. </div>
  262. <blockquote class="layui-elem-quote" style="margin-top: 30px;">
  263. 更多我们未能呈现的示例,还有待您在阅读文档、以及不断使用的过程,去深入挖掘。
  264. </blockquote>
  265. <div style="margin: 15px 0 100px; padding-bottom: 100px;">
  266. </div>
  267. </div>
  268. </div>
  269. <div class="layui-tab-item">
  270. <textarea class="layui-border-box site-demo-text site-demo-code" id="LAY_democode" spellcheck="false" readonly>
  271. <!DOCTYPE html>
  272. <html>
  273. <head>
  274. <meta charset="utf-8">
  275. <title>镜像站@Layui</title>
  276. <meta name="renderer" content="webkit">
  277. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  278. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  279. <link rel="stylesheet" href="/public/layui/dist/css/layui.css" tppabs="http://res.layui.com/layui/dist/css/layui.css" media="all">
  280. <!-- 注意:如果你直接复制所有代码到本地,上述css路径需要改成你本地的 -->
  281. </head>
  282. </textarea>
  283. </div>
  284. <div class="layui-tab-item">
  285. <div class="layui-main">
  286. <p></p>
  287. <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
  288. <legend>相关</legend>
  289. </fieldset>
  290. <a class="layui-btn layui-btn-normal" href="../doc/modules/transfer.html" tppabs="http://www.layui.com/doc/modules/transfer.html" target="_blank">穿梭框文档</a>
  291. </div>
  292. </div>
  293. </div>
  294. </div>
  295. <div class="layui-footer footer footer-demo">
  296. <p>
  297. Copyright &copy; 2021 <a href="../index.html" tppabs="http://www.layui.com/">「本站仅为 layui 文档保留的镜像站点,与官方无关」</a> MIT Licensed</p>
  298. <p>
  299. <a href="../about/disclaimer.html" tppabs="http://www.layui.com/about/disclaimer.html" target="_blank">免责声明</a>
  300. <a href="../about/relatedlinks.html" tppabs="http://www.layui.com/about/relatedlinks.html" target="_blank">友链</a>
  301. <a href="javascript:;" site-event="weixinmp">公众号</a>
  302. </p>
  303. <div class="site-union">
  304. <p class="site-union-desc">
  305. <span>
  306. </span>
  307. </p>
  308. </div>
  309. </div>
  310. <script>
  311. window.global = {
  312. pageType: 'demo'
  313. ,preview: function(){
  314. var preview = document.getElementById('LAY_preview');
  315. return preview ? preview.innerHTML : '';
  316. }()
  317. };
  318. </script>
  319. <div class="site-tree-mobile layui-hide">
  320. <i class="layui-icon layui-icon-spread-left"></i>
  321. </div>
  322. <div class="site-mobile-shade"></div>
  323. <script src="/public/layui/dist/layui.js" tppabs="http://res.layui.com/layui/dist/layui.js?t=1632428048260" charset="utf-8"></script>
  324. <script>
  325. layui.config({
  326. base: '/public/static/lay/modules/layui/'
  327. ,version: '1632428048260'
  328. }).use('global');
  329. </script>
  330. </div>
  331. <div id="LAY_democodejs">
  332. <script>
  333. layui.use(['transfer', 'layer', 'util'], function(){
  334. var $ = layui.$
  335. ,transfer = layui.transfer
  336. ,layer = layui.layer
  337. ,util = layui.util;
  338. //模拟数据
  339. var data1 = [
  340. {"value": "1", "title": "李白"}
  341. ,{"value": "2", "title": "杜甫"}
  342. ,{"value": "3", "title": "苏轼"}
  343. ,{"value": "4", "title": "李清照"}
  344. ,{"value": "5", "title": "鲁迅", "disabled": true}
  345. ,{"value": "6", "title": "巴金"}
  346. ,{"value": "7", "title": "冰心"}
  347. ,{"value": "8", "title": "矛盾"}
  348. ,{"value": "9", "title": "贤心"}
  349. ]
  350. ,data2 = [
  351. {"value": "1", "title": "瓦罐汤"}
  352. ,{"value": "2", "title": "油酥饼"}
  353. ,{"value": "3", "title": "炸酱面"}
  354. ,{"value": "4", "title": "串串香", "disabled": true}
  355. ,{"value": "5", "title": "豆腐脑"}
  356. ,{"value": "6", "title": "驴打滚"}
  357. ,{"value": "7", "title": "北京烤鸭"}
  358. ,{"value": "8", "title": "烤冷面"}
  359. ,{"value": "9", "title": "毛血旺", "disabled": true}
  360. ,{"value": "10", "title": "肉夹馍"}
  361. ,{"value": "11", "title": "臊子面"}
  362. ,{"value": "12", "title": "凉皮"}
  363. ,{"value": "13", "title": "羊肉泡馍"}
  364. ,{"value": "14", "title": "冰糖葫芦", "disabled": true}
  365. ,{"value": "15", "title": "狼牙土豆"}
  366. ]
  367. //基础效果
  368. transfer.render({
  369. elem: '#test1'
  370. ,data: data1
  371. })
  372. //定义标题及数据源
  373. transfer.render({
  374. elem: '#test2'
  375. ,title: ['候选文人', '获奖文人'] //自定义标题
  376. ,data: data1
  377. //,width: 150 //定义宽度
  378. ,height: 210 //定义高度
  379. })
  380. //初始右侧数据
  381. transfer.render({
  382. elem: '#test3'
  383. ,data: data2
  384. ,value: ["1", "3", "5", "7", "9", "11"]
  385. })
  386. //显示搜索框
  387. transfer.render({
  388. elem: '#test4'
  389. ,data: data1
  390. ,title: ['文本墨客', '获奖文人']
  391. ,showSearch: true
  392. })
  393. //数据格式解析
  394. transfer.render({
  395. elem: '#test5'
  396. ,parseData: function(res){
  397. return {
  398. "value": res.id //数据值
  399. ,"title": res.name //数据标题
  400. ,"disabled": res.disabled //是否禁用
  401. ,"checked": res.checked //是否选中
  402. }
  403. }
  404. ,data: [
  405. {"id": "1", "name": "李白"}
  406. ,{"id": "2", "name": "杜甫"}
  407. ,{"id": "3", "name": "贤心"}
  408. ]
  409. ,height: 150
  410. })
  411. //穿梭时的回调
  412. transfer.render({
  413. elem: '#test6'
  414. ,data: data1
  415. ,onchange: function(obj, index){
  416. var arr = ['左边', '右边'];
  417. layer.alert('来自 <strong>'+ arr[index] + '</strong> 的数据:'+ JSON.stringify(obj)); //获得被穿梭时的数据
  418. }
  419. })
  420. //实例调用
  421. transfer.render({
  422. elem: '#test7'
  423. ,data: data1
  424. ,id: 'key123' //定义唯一索引
  425. })
  426. //批量办法定事件
  427. util.event('lay-demoTransferActive', {
  428. getData: function(othis){
  429. var getData = transfer.getData('key123'); //获取右侧数据
  430. layer.alert(JSON.stringify(getData));
  431. }
  432. ,reload:function(){
  433. //实例重载
  434. transfer.reload('key123', {
  435. title: ['文人', '喜欢的文人']
  436. ,value: ['2', '5', '9']
  437. ,showSearch: true
  438. })
  439. }
  440. });
  441. });
  442. </script>
  443. </div>
  444. </body>
  445. </html>