avatar.js 562 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // components/avatar/avatar.js
  2. import {
  3. imgServerUrl
  4. } from '../../config/config.js'
  5. Component({
  6. /**
  7. * 组件的属性列表
  8. */
  9. properties: {
  10. src: { // 头像连接
  11. type: String,
  12. value: '',
  13. observer(data) {
  14. wx.getImageInfo({
  15. src: data,
  16. fail: (res) => {
  17. this.setData({
  18. src: imgServerUrl + '/images/avatar/man.png'
  19. })
  20. }
  21. })
  22. }
  23. },
  24. size: { // 头像大小
  25. type: Number,
  26. value: 200
  27. }
  28. },
  29. /**
  30. * 组件的初始数据
  31. */
  32. data: {
  33. },
  34. /**
  35. * 组件的方法列表
  36. */
  37. methods: {
  38. }
  39. })