c-drawer.vue 1.9 KB

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