Skip to content

Commit

Permalink
fix(core): fix 切换组件 __inited__ 时 computed 数据错误 (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
allen-zh committed Jul 8, 2019
1 parent 6bade52 commit 803bac8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/mars-core/src/base/data.js
Expand Up @@ -70,13 +70,20 @@ export function setData(vm, $mp, isRoot = false) {

// if vm has _computedWatchers and has new data
// set __inited__ true to use VM _computedWatchers data
// need to sync comp rootComputed data
if (
vm._computedWatchers
&& !$mp.data.__inited__
!$mp.data.__inited__
&& vm._computedWatchers
&& Object.keys(vm._computedWatchers).length > 0
&& Object.keys(data).length > 0
) {
data.__inited__ = true;
const {rootComputed, compId} = $mp.data;
let computedProps = {};
if (rootComputed && compId) {
computedProps = rootComputed[compId] || {};
}
data = Object.assign(computedProps, data);
}

if (process.env.NODE_ENV !== 'production' && config.performance && mark) {
Expand Down

0 comments on commit 803bac8

Please sign in to comment.