1. <template>
    2. <div>
    3. <el-dropdown class="mainBtn">
    4. <el-button type="primary" size="mini"
    5. @click="btnClick('')">
    6. {{ mainBtnLabel }}<i class="el-icon-arrow-down el-icon--right"></i>
    7. </el-button>
    8. <div class="dropdownBtn">
    9. <div class="dropButton" :style="'width:100px;height:28px'" v-for="item in buttonData"
    10. :key="item.label"
    11. @click="btnClick(item.methodName,item.type)">
    12. <span class="dropButtonSpan">{{ item.label }}</span>
    13. </div>
    14. </div>
    15. <el-dropdown-menu class="hidden">
    16. </el-dropdown-menu>
    17. </el-dropdown>
    18. </div>
    19. </template>
    20. <script>
    21. export default {
    22. name: "ZjdsjjgCommonDropdownButton",
    23. props: {
    24. mainBtnLabel: {
    25. type: String,
    26. default: "保存并关闭"
    27. },
    28. buttonData: {
    29. type: Array,
    30. default: () => {
    31. return [
    32. {
    33. label: "保存",
    34. method: "",
    35. },
    36. ]
    37. }
    38. },
    39. },
    40. methods: {
    41. btnClick(methodName, type) {
    42. methodName = methodName || "" ? methodName : "saveAndBack";
    43. if (!type) {
    44. type = "";
    45. }
    46. this.$emit(methodName, type);
    47. },
    48. },
    49. computed: {},
    50. data() {
    51. return {
    52. showBtn: false,
    53. }
    54. }
    55. }
    56. </script>
    57. <style scoped>
    58. .mainBtn:hover .dropdownBtn {
    59. display: block;
    60. }
    61. .mainBtn .dropdownBtn {
    62. display: none;
    63. }
    64. .dropdownBtn {
    65. position: absolute;
    66. z-index: 999;
    67. line-height: 0;
    68. box-shadow: 0 1px 2px -0.8px #333333;
    69. background-color: #FFFFFF;
    70. padding-top: 5px;
    71. /*display: none;*/
    72. }
    73. .hidden {
    74. display: none;
    75. }
    76. .dropButton {
    77. height: 25px;
    78. text-align: center;
    79. line-height: 25px;
    80. cursor: pointer;
    81. margin-bottom: 5px;
    82. }
    83. .dropButton:before {
    84. content: '';
    85. display: inline-block;
    86. vertical-align: middle;
    87. height: 100%;
    88. }
    89. .dropButton:hover {
    90. background-color: #F1F4F7;
    91. color: #409EFF;
    92. }
    93. .dropButtonSpan {
    94. font-size: 12px;
    95. font-family: 'Microsoft YaHei 微软雅黑', serif;
    96. }
    97. </style>

    GIF1.gif