{"size": 1000, "ext": "js", "max_stars_repo_path": "miniprogram/components/avatar/avatar.js", "max_stars_repo_name": "jasongao97/natianyue", "max_stars_repo_stars_event_min_datetime": "2018-07-07T09:11:12.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-21T06:29:17.000Z", "max_issues_repo_path": "miniprogram/components/avatar/avatar.js", "max_issues_repo_name": "jasongao97/natianyue", "max_issues_repo_issues_event_min_datetime": "2021-11-15T03:57:31.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-30T02:37:22.000Z", "max_forks_repo_path": "miniprogram/components/avatar/avatar.js", "max_forks_repo_name": "jasongao97/natianyue", "max_forks_repo_forks_event_min_datetime": "2020-10-02T00:33:02.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-21T06:21:31.000Z"}
{"max_stars_count": 15, "max_issues_count": 2, "max_forks_count": 5, "avg_line_length": 14.0845070423, "max_line_length": 38, "alphanum_fraction": 0.434}
// components/avatar/avatar.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    src: {
      type: String,
      value: '',
    },
    animation: {
      type: Boolean,
      value: true
    },
    avatarStyle: {
      type: String,
      value: ''
    },
    disable: {
      type: Boolean,
      value: false
    }
  },

  observers: {
    src: function (src) {
      if (this.lastSrc === src) return
      if (src) {
        this.setData({
          loaded: false,
          failed: false
        })
      } else {
        this.setData({
          loaded: true,
          failed: true
        })
      }

      this.lastSrc = src
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    loaded: false,
    failed: false,
    imageSrc: ''
  },

  /**
   * 组件的方法列表
   */
  methods: {
    handleLoaded: function () {
      this.setData({
        loaded: true
      })
    },

    handleError: function (event) {
      this.setData({
        loaded: true,
        failed: true
      })
    }
  }
})
