Skip to content

Commit

Permalink
组件和page拥有私有数据
Browse files Browse the repository at this point in the history
  • Loading branch information
dntzhang committed Oct 30, 2018
1 parent ffe9d16 commit 8c5b932
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
8 changes: 7 additions & 1 deletion packages/westore/pages/index/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ create(store, {
b: { arr: [ ] },
firstName: null,
lastName: null,
pureProp: null
pureProp: null,
aaa: '私有数据,不放在store'
},

onShow() {
Expand Down Expand Up @@ -49,6 +50,11 @@ create(store, {
}
})
}
setTimeout(() => {
this.setData({
aaa:'使用 setData 修改不放在store的私有数据'
})
}, 2000)

setTimeout(() => {
// this.store.data.motto = 'Hello Store222'
Expand Down
1 change: 1 addition & 0 deletions packages/westore/pages/index/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<text class="log-item">{{index + 1}}. {{item.name}}</text>
</view>
<view>FullName: {{fullName}}</view>
<view>aaa: {{aaa}}</view>
<hello></hello>
<test-pure-component bind:random="onRandom" pureProp="{{pureProp}}"></test-pure-component>
</view>
2 changes: 1 addition & 1 deletion packages/westore/utils/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function create(store, option) {
extendStoreMethod(store)
}
getApp().globalData && (getApp().globalData.store = store)
option.data = store.data
//option.data = store.data
const onLoad = option.onLoad
walk(store.data)
option.onLoad = function (e) {
Expand Down
2 changes: 1 addition & 1 deletion utils/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function create(store, option) {
extendStoreMethod(store)
}
getApp().globalData && (getApp().globalData.store = store)
option.data = store.data
//option.data = store.data
const onLoad = option.onLoad
walk(store.data)
option.onLoad = function (e) {
Expand Down

0 comments on commit 8c5b932

Please sign in to comment.