Skip to content

Commit

Permalink
x-img: re-initialize when src is changed (fix #1901)
Browse files Browse the repository at this point in the history
  • Loading branch information
airyland committed Sep 12, 2017
1 parent 6eb51b7 commit b7aa4ec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/components/x-img/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ export default {
methods: {
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,
Expand Down Expand Up @@ -69,6 +73,11 @@ export default {
default: 0
}
},
watch: {
src (val) {
this.init()
}
},
beforeDestroy () {
this.blazy && this.blazy.destroy()
this.blazy = null
Expand Down
5 changes: 5 additions & 0 deletions src/components/x-img/metas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ props:
en: delay execute lazyload function because sometimes transition between routes will cause problems
zh-CN: 延迟执行,在存在路由过渡时立即执行可能会导致进入页面后并不会正确加载图片。该属性在 2.5.4 后已经不推荐使用,推荐使用 BusPlugin 来通知组件页面已经载入完成。
changes:
next:
en:
- '[fix] re-initialize when src is changed #1901'
zh-CN:
- '[fix] 当 src 变化时重新初始化 #1901'
v2.5.4:
en:
- '[feature] re-init after router-view transition is finished'
Expand Down

0 comments on commit b7aa4ec

Please sign in to comment.