mirror of https://github.com/vuejs/core.git
fix(reactivity): keep previous effect scope
This commit is contained in:
parent
be65b98a33
commit
8dec243dc1
|
@ -62,11 +62,13 @@ export class EffectScope {
|
|||
}
|
||||
}
|
||||
|
||||
prevScope: EffectScope | undefined
|
||||
/**
|
||||
* This should only be called on non-detached scopes
|
||||
* @internal
|
||||
*/
|
||||
on() {
|
||||
this.prevScope = activeEffectScope
|
||||
activeEffectScope = this
|
||||
}
|
||||
|
||||
|
@ -75,7 +77,7 @@ export class EffectScope {
|
|||
* @internal
|
||||
*/
|
||||
off() {
|
||||
activeEffectScope = this.parent
|
||||
activeEffectScope = this.prevScope
|
||||
}
|
||||
|
||||
stop(fromParent?: boolean) {
|
||||
|
|
|
@ -23,12 +23,16 @@ export default defineComponent({
|
|||
const container = document.createElement('li')
|
||||
append(container, node)
|
||||
|
||||
const update = () => {
|
||||
renderEffect(() => {
|
||||
const [item, index] = block.s
|
||||
node.textContent = `${index}. ${item}`
|
||||
}
|
||||
renderEffect(update)
|
||||
return [container, update]
|
||||
})
|
||||
|
||||
renderEffect(() => {
|
||||
const [item, index] = block.s
|
||||
node.textContent = `${index}/ ${item}`
|
||||
})
|
||||
return container
|
||||
},
|
||||
(item, index) => index,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue