Skip to content

Commit

Permalink
fix(taro): 优化数据结构
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam committed Apr 25, 2018
1 parent 487d9a5 commit 8781395
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/taro/src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Component {

_initData ($root, $parent) {
this.$app = getApp()
this.$root = $root || this
this.$root = $root || null
this.$parent = $parent || null
this.defaultData = {}
this.$data = $parent ? $parent.$data : {}
Expand All @@ -42,7 +42,7 @@ class Component {

if (this.$$components && !isEmptyObject(this.$$components)) {
Object.getOwnPropertyNames(this.$$components).forEach(name => {
this.$$components[name]._initData(this.$root, this)
this.$$components[name]._initData(this.$root || this, this)
})
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/taro/src/lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ export function updateComponent (component, update) {
}

function doUpdate (component, update) {
const $data = component.$root ? component.$root.$data : component.$data
component.$scope._setData(
{ ...component.$root.$data },
{ ...$data },
function () {
if (component._pendingCallbacks) {
while (component._pendingCallbacks.length) {
Expand Down

0 comments on commit 8781395

Please sign in to comment.