index.js 1.4 KB

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