confirm-button.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <div class="confirm-button">
  3. <a-popconfirm
  4. :title="title"
  5. :ok-text="okText"
  6. :cancel-text="cancelText"
  7. @confirm="confirm"
  8. @cancel="close"
  9. >
  10. <a-button v-if="buttonStatus" :type="buttonType">{{ text }}</a-button>
  11. <div v-else class="button_blue">{{ text }}</div>
  12. </a-popconfirm>
  13. </div>
  14. </template>
  15. <script lang="ts">
  16. import { defineComponent } from "vue";
  17. export default defineComponent({
  18. emits: ["confirm", "close"],
  19. props: {
  20. title: {
  21. type: String,
  22. default: "确认该操作吗?", //提示信息
  23. },
  24. okText: {
  25. type: String,
  26. default: "确认", //确认按钮
  27. },
  28. cancelText: {
  29. type: String,
  30. default: "取消", //取消按钮
  31. },
  32. text: {
  33. type: String,
  34. default: "确认", //按钮文案
  35. },
  36. buttonStatus: {
  37. type: Boolean,
  38. default: true, //按钮类型 默认为按钮
  39. },
  40. buttonType: {
  41. type: String,
  42. default: "primary", //按钮类型 默认为按钮
  43. },
  44. },
  45. setup() {},
  46. methods: {
  47. confirm() {
  48. this.$emit("confirm");
  49. // 确认
  50. },
  51. close() {
  52. this.$emit("close");
  53. // 取消
  54. },
  55. },
  56. });
  57. </script>