t.html 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <!--
  2. * @Description: 测试弹窗功能
  3. * @Autor: kindring
  4. * @Date: 2021-10-26 11:27:22
  5. * @LastEditors: kindring
  6. * @LastEditTime: 2021-10-26 15:17:33
  7. * @LastDescript:
  8. -->
  9. <!DOCTYPE html>
  10. <html lang="en">
  11. <head>
  12. <meta charset="UTF-8">
  13. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  14. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  15. <title>测试</title>
  16. <script src="./quickDom.js"></script>
  17. <style>
  18. .div1 {
  19. width: 200px;
  20. height: 200px;
  21. background-color: aqua;
  22. }
  23. </style>
  24. </head>
  25. <body>
  26. <button onclick="show()">弹窗tip</button>
  27. <button onclick="show()">弹窗tip</button>
  28. <button onclick="show()">弹窗tip</button>
  29. <div id="parent" class="div1">
  30. </div>
  31. <div id="pop1">
  32. 这是弹窗1
  33. </div>
  34. <div id="pop2">
  35. 这是弹窗2
  36. </div>
  37. <script>
  38. let tip = new CustomPop({
  39. type: 'tip'
  40. })
  41. let n = 0;
  42. function show() {
  43. tip.show('show:' + n);
  44. n++
  45. }
  46. console.log(tip);
  47. tip.show('测试error', 'error')
  48. tip.show('测试ok', 'ok')
  49. tip.show('测试waring', 'warn')
  50. tip.show('测试info')
  51. let c = new CustomPop({
  52. type: 'custom',
  53. // mask: true,
  54. autoClose: true,
  55. el: document.getElementById('parent'),
  56. centerDoms: [{
  57. key: 'pop1',
  58. el: document.getElementById('pop1')
  59. }, {
  60. key: 'pop2',
  61. el: document.getElementById('pop2')
  62. }]
  63. })
  64. console.log(c);
  65. c.show('pop1')
  66. setTimeout(() => {
  67. c.hide('pop1')
  68. }, 2000);
  69. setTimeout(() => {
  70. c.show('pop2')
  71. }, 4000);
  72. setTimeout(() => {
  73. c.show('pop1')
  74. }, 6000);
  75. setTimeout(() => {
  76. c.show('测试功能呢')
  77. }, 6000);
  78. setTimeout(() => {
  79. c.show('pop1')
  80. }, 7000);
  81. setTimeout(() => {
  82. c.show('pop1')
  83. }, 7500);
  84. </script>
  85. </body>
  86. </html>