index.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <div class="btn-tip">
  3. <el-popover ref="popover" placement="top" :width="popoverWidth" v-model="visible">
  4. <p>{{tip}}</p>
  5. <div style="text-align: right; margin: 0">
  6. <el-button :size="size" type="text" @click="visible = false">取消</el-button>
  7. <el-button type="primary" size="mini" @click="onConfirm">确定</el-button>
  8. </div>
  9. </el-popover>
  10. <el-button
  11. class="w-full"
  12. :disabled="disabled"
  13. :type="type"
  14. :size="size"
  15. v-bind="$attrs"
  16. v-popover:popover
  17. @click.stop
  18. >
  19. <slot></slot>
  20. </el-button>
  21. </div>
  22. </template>
  23. <script>
  24. export default {
  25. data() {
  26. return {
  27. visible: false
  28. };
  29. },
  30. props: {
  31. type: {
  32. default: "danger"
  33. },
  34. size: {
  35. default: ""
  36. },
  37. tip: {
  38. default: "确定要删除数据吗?"
  39. },
  40. disabled: {
  41. default: false
  42. },
  43. popoverWidth: {
  44. default: 160
  45. }
  46. },
  47. methods: {
  48. onConfirm() {
  49. this.visible = false;
  50. this.$emit("click");
  51. }
  52. }
  53. };
  54. </script>
  55. <style lang="scss" >
  56. .btn-tip {
  57. display: inline-block;
  58. }
  59. .el-button + .btn-tip {
  60. margin-left: 10px;
  61. }
  62. .btn-tip + .el-button {
  63. margin-left: 10px;
  64. }
  65. .btn-tip + .btn-tip {
  66. margin-left: 10px;
  67. }
  68. </style>