gracePopupMenu.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template name="gracePopupMenu">
  2. <view>
  3. <view class="grace-popup-mask" v-if="show" @tap.stop="hideMenu" @touchmove.stop="" :style="{background:background, zIndex:zIndex}"></view>
  4. <view class="grace-popup-menu" v-if="show" :style="{top:top+'px', width:menuWidth, zIndex:zIndex+1}">
  5. <view :class="['grace-rows', 'arrow-d-'+arrowDirection]" v-if="isArrow">
  6. <view class="arrow-up" :style="{borderBottomColor:bgColor, margin:arrowMargin}"></view>
  7. </view>
  8. <view :style="{background:bgColor, width:menuWidth, borderRadius:borderRadius}"><slot></slot></view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. name: "gracePopupMenu",
  15. props: {
  16. show:{
  17. type : Boolean,
  18. default : false
  19. },
  20. top:{
  21. type : Number,
  22. default : 0
  23. },
  24. bgColor:{
  25. type : String,
  26. default :'#FFFFFF'
  27. },
  28. menuWidth :{
  29. type : String,
  30. default : '258rpx'
  31. },
  32. background : {
  33. type : String,
  34. default : 'rgba(0,0,0, 0.3)'
  35. },
  36. borderRadius:{
  37. type : String,
  38. default:'0rpx'
  39. },
  40. zIndex : {type:Number, default:3},
  41. isArrow:{type:Boolean, default:true},
  42. arrowDirection:{type:String, default:"right"},
  43. arrowMargin:{type:String, default:"0 12rpx"}
  44. },
  45. methods: {
  46. hideMenu : function() {
  47. this.$emit('hideMenu');
  48. }
  49. },
  50. }
  51. </script>
  52. <style scoped>
  53. .grace-popup-menu{width:258rpx; padding:10rpx; right:0px; top:0px; position:absolute; z-index:3;}
  54. .grace-popup-mask{background:rgba(0,0,0, 0.3); width:100%; height:100%; position:fixed; left:0; top:0; z-index:4;}
  55. .arrow-up {
  56. width:0;
  57. height:0;
  58. border-left:18rpx solid transparent;
  59. border-right:18rpx solid transparent;
  60. border-bottom:18rpx solid #FFFFFF;
  61. }
  62. .arrow-d-right{justify-content:flex-end;}
  63. .arrow-d-center{justify-content:center;}
  64. .arrow-d-left{justify-content:flex-start;}
  65. </style>