vux,x-img组件源码疑惑

0 0 vux vue.js
ㄨ風影ミ红ん馆
ㄨ風影ミ红ん馆

声望值:110 0人

2019-01-11 15:59:12 提问

关注 0关注

收藏 0收藏, 144浏览

    created () {
        this.$vux && 
        this.$vux.bus && 
        this.$vux.bus.$on('vux:after-view-enter',this.init)
    },
    init () {
      const _this = this
      this.blazy && this.blazy.destroy()
      this.$el.src = this.defaultSrc
      this.$el.className = this.$el.className.replace('b-loaded', '')
      this.blazy = new Blazy({
        scroller: this.scroller,
        container: this.container,
        selector: `#vux-ximg-${this.uuid}`,
        offset: _this.offset,
        errorClass: _this.errorClass,
        successClass: _this.successClass,
        success (ele) {
          _this.$emit('on-success', _this.src, ele)
        },
        error (ele, msg) {
          _this.$emit('on-error', _this.src, ele, msg)
        }
      })
  },
  mounted () {
    this.$el.setAttribute('id', `vux-ximg-${this.uuid}`)
    this.$nextTick(() => {
      setTimeout(() => {
        this.init()
      }, this.delay)
    })
    detectWebp()
  },

为什么这里要走两遍init方法,然后在demos页面时却只走了一遍on-successs事件

请先 登录 后评论

0个回答

注册新账号

悬赏追问
10
  • 10
  • 20
  • 50
  • 100
  • 200
  • 输入数值
发布追问