index.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <title>代码修饰</title>
  2. <div class="layui-card layadmin-header">
  3. <div class="layui-breadcrumb" lay-filter="breadcrumb">
  4. <a lay-href="">主页</a>
  5. <a><cite>组件</cite></a>
  6. <a><cite>代码修饰</cite></a>
  7. </div>
  8. </div>
  9. <div class="layui-fluid">
  10. <div class="layui-row layui-col-space15">
  11. <div class="layui-col-md12">
  12. <div class="layui-card">
  13. <div class="layui-card-header">默认修饰</div>
  14. <div class="layui-card-body">
  15. <pre class="layui-code">//在里面存放任意的代码
  16. Lay.fn.event = function(modName, events, params){
  17. var that = this, result = null, filter = events.match(/\(.*\)$/)||[];
  18. var set = (events = modName + '.'+ events).replace(filter, '');
  19. };
  20. </pre>
  21. </div>
  22. </div>
  23. <div class="layui-card">
  24. <div class="layui-card-header">notepad风格</div>
  25. <div class="layui-card-body">
  26. <pre class="layui-code" lay-title="JavaScript" lay-skin="notepad">//代码区域
  27. Lay.fn.event = function(modName, events, params){
  28. var that = this, result = null, filter = events.match(/\(.*\)$/)||[];
  29. var set = (events = modName + '.'+ events).replace(filter, '');
  30. };
  31. </pre>
  32. </div>
  33. </div>
  34. <div class="layui-card">
  35. <div class="layui-card-header">代码中的代码</div>
  36. <div class="layui-card-body">
  37. <pre class="layui-code">//代码区域
  38. Lay.fn.event = function(modName, events, params){
  39. var that = this, result = null, filter = events.match(/\(.*\)$/)||[];
  40. var set = (events = modName + '.'+ events).replace(filter, '');
  41. };
  42. <pre class="layui-code">//代码区域
  43. Lay.fn.event = function(modName, events, params){
  44. var that = this, result = null, filter = events.match(/\(.*\)$/)||[];
  45. var set = (events = modName + '.'+ events).replace(filter, '');
  46. };
  47. </pre>
  48. </pre>
  49. <pre class="layui-code" lay-skin="notepad">//代码区域
  50. Lay.fn.event = function(modName, events, params){
  51. var that = this, result = null, filter = events.match(/\(.*\)$/)||[];
  52. var set = (events = modName + '.'+ events).replace(filter, '');
  53. };
  54. <pre class="layui-code" lay-skin="notepad">//代码区域
  55. Lay.fn.event = function(modName, events, params){
  56. var that = this, result = null, filter = events.match(/\(.*\)$/)||[];
  57. var set = (events = modName + '.'+ events).replace(filter, '');
  58. };
  59. <pre class="layui-code" lay-skin="notepad">//代码区域
  60. Lay.fn.event = function(modName, events, params){
  61. var that = this, result = null, filter = events.match(/\(.*\)$/)||[];
  62. var set = (events = modName + '.'+ events).replace(filter, '');
  63. };
  64. <pre class="layui-code" lay-skin="notepad">//代码区域
  65. Lay.fn.event = function(modName, events, params){
  66. var that = this, result = null, filter = events.match(/\(.*\)$/)||[];
  67. var set = (events = modName + '.'+ events).replace(filter, '');
  68. };
  69. <pre class="layui-code" lay-skin="notepad">//代码区域
  70. Lay.fn.event = function(modName, events, params){
  71. var that = this, result = null, filter = events.match(/\(.*\)$/)||[];
  72. var set = (events = modName + '.'+ events).replace(filter, '');
  73. };
  74. </pre>
  75. </pre>
  76. </pre>
  77. </pre>
  78. </pre>
  79. </div>
  80. </div>
  81. <div class="layui-card">
  82. <div class="layui-card-header">固定高度</div>
  83. <div class="layui-card-body">
  84. <pre class="layui-code" lay-height="150px">//代码区域
  85. Lay.fn.event = function(modName, events, params){
  86. var that = this, result = null, filter = events.match(/\(.*\)$/)||[]; //提取事件过滤器
  87. var set = (events = modName + '.'+ events).replace(filter, ''); //获取事件本体名
  88. var callback = function(_, item){
  89. var res = item &amp;&amp; item.call(that, params);
  90. res === false &amp;&amp; result === null &amp;&amp; (result = false);
  91. };
  92. layui.each(config.event[set], callback);
  93. filter[0] &amp;&amp; layui.each(config.event[events], callback); //执行过滤器中的事件
  94. return result;
  95. };
  96. </pre>
  97. </div>
  98. </div>
  99. <div class="layui-card">
  100. <div class="layui-card-header">XXX</div>
  101. <div class="layui-card-body">
  102. </div>
  103. </div>
  104. <div class="layui-card">
  105. <div class="layui-card-header">XXX</div>
  106. <div class="layui-card-body">
  107. </div>
  108. </div>
  109. <div class="layui-card">
  110. <div class="layui-card-header">XXX</div>
  111. <div class="layui-card-body">
  112. </div>
  113. </div>
  114. </div>
  115. </div>
  116. </div>
  117. <script>
  118. layui.use(['admin', 'code'], function(){
  119. layui.code({
  120. elem: 'pre'
  121. });
  122. });
  123. </script>