提交 db032655 编写于 作者: Q qiang

fix: 解决swiper组件动态设置current-item-id不生效的问题

上级 de835654
......@@ -12,14 +12,6 @@ export default {
default: ''
}
},
watch: {
itemId (val, oldVal) {
this._itemIdUpdated(val, oldVal)
}
},
created () {
this._itemIdUpdated(this.itemId, this.itemId)
},
mounted: function () {
var $el = this.$el
$el.style.position = 'absolute'
......@@ -31,14 +23,6 @@ export default {
callback()
})
}
},
methods: {
_itemIdUpdated (val, oldVal) {
var $parent = this.$parent
if ($parent && typeof $parent._itemIdUpdated === 'function') {
$parent._itemIdUpdated(this, val, oldVal)
}
}
}
}
</script>
......
......@@ -69,8 +69,7 @@ export default {
currentItemIdSync: this.currentItemId || '',
userTracking: false,
currentChangeSource: '',
items: [],
itemIdItemMap: {}
items: []
}
},
computed: {
......@@ -143,9 +142,6 @@ export default {
displayMultipleItemsNumber () {
this._resetLayout()
}
// itemIdItemMap () {
// this._resetLayout()
// }
},
created () {
this._invalid = true
......@@ -172,14 +168,6 @@ export default {
this._cancelSchedule()
},
methods: {
_itemIdUpdated (item, val, oldVal) {
if (oldVal) {
this.$set(this.itemIdItemMap, oldVal, null)
}
if (val) {
this.$set(this.itemIdItemMap, val, item.$vnode)
}
},
_inintAutoplay (enable) {
if (enable) {
this._scheduleAutoplay()
......@@ -191,7 +179,16 @@ export default {
* 页面变更检查和同步
*/
_currentCheck () {
var current = this.items.indexOf(this.itemIdItemMap[this.currentItemId])
var current = -1
if (this.currentItemId) {
for (let i = 0, items = this.items; i < items.length; i++) {
let componentInstance = items[i].componentInstance
if (componentInstance && componentInstance.itemId === this.currentItemId) {
current = i
break
}
}
}
if (current < 0) {
current = Math.round(this.current) || 0
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册