c-drawer.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view>
  3. <uni-drawer ref="drawerShow" :mode="drawer.mode" :maskClick="false" 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="drawerClose()"></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. drawerClose() {
  42. const that = this;
  43. that.$refs.drawerShow.close();
  44. that.$emit('toClose')
  45. }
  46. },
  47. watch: {
  48. drawer(newVal) {
  49. const that = this;
  50. if (newVal.show == true) that.drawerOpen();
  51. else if (newVal.show == false) that.drawerClose();
  52. }
  53. }
  54. }
  55. </script>
  56. <style lang="scss">
  57. .drawer {
  58. display: flex;
  59. flex-direction: column;
  60. width: 77vw;
  61. height: 100vh;
  62. .drawer_1 {
  63. display: flex;
  64. justify-content: space-between;
  65. padding: 2vw;
  66. .left {
  67. flex-grow: 1;
  68. font-weight: bold;
  69. padding: 1vw 0;
  70. font-size: 16px;
  71. font-family: monospace;
  72. }
  73. }
  74. .drawer_2 {
  75. flex-grow: 1;
  76. position: relative;
  77. padding: 0 2vw;
  78. .info {
  79. padding: 0 2vw;
  80. }
  81. }
  82. }
  83. .scroll-view {
  84. position: absolute;
  85. top: 0;
  86. left: 0;
  87. right: 0;
  88. bottom: 0;
  89. .list-scroll-view {
  90. display: flex;
  91. flex-direction: column;
  92. padding: 0 !important;
  93. }
  94. }
  95. </style>