提交 db032655 编写于 作者: Q qiang

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

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