pop-menu.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <view>
  3. <view class="pop-menu" @tap="onClose()" @contextmenu.prevent=""></view>
  4. <view class="menu" :style="menuStyle">
  5. <view class="menu-item" v-for="(item) in items" :key="item.key" @click.prevent="onSelectMenu(item)">
  6. <uni-icons :type="item.icon" :style="itemStyle(item)" size="22"></uni-icons>
  7. <text :style="itemStyle(item)"> {{item.name}}</text>
  8. </view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. export default {
  14. name: "pop-menu",
  15. data() {
  16. return {}
  17. },
  18. props: {
  19. menuStyle: {
  20. type: String
  21. },
  22. items: {
  23. type: Array
  24. }
  25. },
  26. methods: {
  27. onSelectMenu(item) {
  28. this.$emit("select", item);
  29. },
  30. onClose() {
  31. this.$emit("close");
  32. },
  33. itemStyle(item){
  34. if(item.color){
  35. return `color:${item.color};`
  36. }
  37. return `color:#4f76e6;`;
  38. }
  39. }
  40. }
  41. </script>
  42. <style lang="scss" scoped>
  43. .pop-menu {
  44. position: fixed;
  45. left: 0;
  46. top: 0;
  47. right: 0;
  48. bottom: 0;
  49. width: 100%;
  50. height: 100%;
  51. background-color: #333;
  52. z-index: 99;
  53. opacity: 0.5;
  54. }
  55. .menu {
  56. position: fixed;
  57. border: 1px solid #b4b4b4;
  58. border-radius: 7px;
  59. overflow: hidden;
  60. background-color: #f5f6ff;
  61. z-index: 100;
  62. .menu-item {
  63. height: 25px;
  64. min-width: 150rpx;
  65. line-height: 25px;
  66. font-size: 18px;
  67. display: flex;
  68. padding: 10px;
  69. justify-content: center;
  70. border-bottom: 1px solid #d0d0d8;
  71. }
  72. }
  73. </style>