index.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { VantComponent } from '../common/component';
  2. import { button } from '../mixins/button';
  3. VantComponent({
  4. mixins: [button],
  5. classes: ['custom-class', 'loading-class', 'error-class', 'image-class'],
  6. props: {
  7. src: {
  8. type: String,
  9. observer() {
  10. this.setData({
  11. error: false,
  12. loading: true,
  13. });
  14. },
  15. },
  16. round: Boolean,
  17. width: null,
  18. height: null,
  19. radius: null,
  20. lazyLoad: Boolean,
  21. useErrorSlot: Boolean,
  22. useLoadingSlot: Boolean,
  23. showMenuByLongpress: Boolean,
  24. fit: {
  25. type: String,
  26. value: 'fill',
  27. },
  28. showError: {
  29. type: Boolean,
  30. value: true,
  31. },
  32. showLoading: {
  33. type: Boolean,
  34. value: true,
  35. },
  36. },
  37. data: {
  38. error: false,
  39. loading: true,
  40. viewStyle: '',
  41. },
  42. methods: {
  43. onLoad(event) {
  44. this.setData({
  45. loading: false,
  46. });
  47. this.$emit('load', event.detail);
  48. },
  49. onError(event) {
  50. this.setData({
  51. loading: false,
  52. error: true,
  53. });
  54. this.$emit('error', event.detail);
  55. },
  56. onClick(event) {
  57. this.$emit('click', event.detail);
  58. },
  59. },
  60. });