index.js 568 B

123456789101112131415161718192021
  1. import { VantComponent } from '../common/component';
  2. const PRESETS = ['error', 'search', 'default', 'network'];
  3. VantComponent({
  4. props: {
  5. description: String,
  6. image: {
  7. type: String,
  8. value: 'default',
  9. },
  10. },
  11. created() {
  12. if (PRESETS.indexOf(this.data.image) !== -1) {
  13. this.setData({
  14. imageUrl: `https://img.yzcdn.cn/vant/empty-image-${this.data.image}.png`,
  15. });
  16. }
  17. else {
  18. this.setData({ imageUrl: this.data.image });
  19. }
  20. },
  21. });