c-drawer.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <view>
  3. <uni-drawer ref="drawerShow" :mode="drawer.mode" :maskClick="true" :width="290">
  4. <view class="drawer">
  5. <view class="drawer_1">
  6. <view class="left textOver">
  7. {{drawer.title||'弹窗'}}
  8. </view>
  9. <view class="right">
  10. <uni-icons type="clear" size="30" @tap="toClose()"></uni-icons>
  11. </view>
  12. </view>
  13. <view class="drawer_2">
  14. <scroll-view scroll-y="true" class="scroll-view">
  15. <view class="list-scroll-view">
  16. <view class="info">
  17. <slot></slot>
  18. </view>
  19. </view>
  20. </scroll-view>
  21. </view>
  22. </view>
  23. </uni-drawer>
  24. </view>
  25. </template>
  26. <script>
  27. export default {
  28. props: {
  29. drawer: {
  30. type: Object
  31. }
  32. },
  33. data() {
  34. return {};
  35. },
  36. methods: {
  37. drawerOpen() {
  38. const that = this;
  39. that.$refs.drawerShow.open();
  40. },
  41. toClose() {
  42. const that = this;
  43. that.$emit('toClose')
  44. },
  45. drawerClose() {
  46. const that = this;
  47. that.$refs.drawerShow.close();
  48. }
  49. },
  50. watch: {
  51. drawer(newVal, oldVal) {
  52. const that = this;
  53. if (newVal.show == true && oldVal.show == false) that.drawerOpen();
  54. else if (newVal.show == false && oldVal.show == true) that.drawerClose();
  55. }
  56. }
  57. }
  58. </script>
  59. <style lang="scss">
  60. .drawer {
  61. display: flex;
  62. flex-direction: column;
  63. width: 77vw;
  64. height: 100vh;
  65. .drawer_1 {
  66. display: flex;
  67. justify-content: space-between;
  68. padding: 2vw;
  69. .left {
  70. flex-grow: 1;
  71. font-weight: bold;
  72. padding: 1vw 0;
  73. font-size: 16px;
  74. font-family: monospace;
  75. }
  76. }
  77. .drawer_2 {
  78. flex-grow: 1;
  79. position: relative;
  80. padding: 0 2vw;
  81. .info {
  82. padding: 0 2vw;
  83. }
  84. }
  85. }
  86. .scroll-view {
  87. position: absolute;
  88. top: 0;
  89. left: 0;
  90. right: 0;
  91. bottom: 0;
  92. .list-scroll-view {
  93. display: flex;
  94. flex-direction: column;
  95. padding: 0 !important;
  96. }
  97. }
  98. </style>