提交 1be4f0fd 编写于 作者: Q qiang

fix(App): 修复部分情况下 v-for 渲染列表事件错乱的问题 question/112100

上级 49e5af92
......@@ -13,9 +13,14 @@ import {
PAGE_CREATE,
PAGE_CREATED,
MOUNTED_DATA,
UPDATED_DATA
UPDATED_DATA,
VD_SYNC_VERSION
} from '../../../constants'
import {
generateId
} from '../../../helpers/util'
import {
removeVdSync,
registerVdSync
......@@ -113,7 +118,18 @@ export class VDomSync {
}
addVm (vm) {
this.vms[vm._$id] = vm
const id = vm._$id
const oldVm = this.vms[id]
if (oldVm) {
const newId = generateId(oldVm, oldVm.$parent, VD_SYNC_VERSION)
oldVm._$id = newId
this.vms[newId] = oldVm
this.elements.forEach(element => {
const cid = element.cid
element.cid = cid === id ? newId : cid
})
}
this.vms[id] = vm
}
removeVm (vm) {
......
......@@ -35,6 +35,17 @@ export class VDomSync {
this.updateBatchVData.push([cid, data])
}
addVm (vm) {
const id = vm._$id
const oldVm = this.vms[id]
if (oldVm) {
const newId = generateId(oldVm, findParent(oldVm), this.version)
oldVm._$id = newId
this.vms[newId] = oldVm
}
this.vms[id] = vm
}
initVm (vm) {
vm._$id = generateId(vm, findParent(vm), this.version)
let vData = this.addBatchVData[vm._$id]
......@@ -50,7 +61,7 @@ export class VDomSync {
const [data, options] = vData
Object.assign(vm.$options, options)
vm.$r = data || Object.create(null)
this.vms[vm._$id] = vm
this.addVm(vm)
}
sendUIEvent (cid, nid, event) {
......@@ -89,4 +100,4 @@ export class VDomSync {
})
this.updateBatchVData.length = 0
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册