index.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { VantComponent } from '../common/component';
  2. import { button } from '../mixins/button';
  3. import { openType } from '../mixins/open-type';
  4. VantComponent({
  5. mixins: [button, openType],
  6. props: {
  7. show: Boolean,
  8. title: String,
  9. cancelText: String,
  10. description: String,
  11. round: {
  12. type: Boolean,
  13. value: true,
  14. },
  15. zIndex: {
  16. type: Number,
  17. value: 100,
  18. },
  19. actions: {
  20. type: Array,
  21. value: [],
  22. },
  23. overlay: {
  24. type: Boolean,
  25. value: true,
  26. },
  27. closeOnClickOverlay: {
  28. type: Boolean,
  29. value: true,
  30. },
  31. closeOnClickAction: {
  32. type: Boolean,
  33. value: true,
  34. },
  35. safeAreaInsetBottom: {
  36. type: Boolean,
  37. value: true,
  38. },
  39. },
  40. methods: {
  41. onSelect(event) {
  42. const { index } = event.currentTarget.dataset;
  43. const item = this.data.actions[index];
  44. if (item && !item.disabled && !item.loading) {
  45. this.$emit('select', item);
  46. if (this.data.closeOnClickAction) {
  47. this.onClose();
  48. }
  49. }
  50. },
  51. onCancel() {
  52. this.$emit('cancel');
  53. },
  54. onClose() {
  55. this.$emit('close');
  56. },
  57. onClickOverlay() {
  58. this.$emit('click-overlay');
  59. this.onClose();
  60. },
  61. },
  62. });