Skip to content

Commit

Permalink
feat(with-weapp): 支持 globalData
Browse files Browse the repository at this point in the history
  • Loading branch information
yuche authored and luckyadam committed Nov 19, 2018
1 parent f028bfe commit 2a387bf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/taro-with-weapp/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, ComponentLifecycle, internal_safe_set as safeSet } from '@tarojs/taro'
import Taro, { Component, ComponentLifecycle, internal_safe_set as safeSet } from '@tarojs/taro'

type WeappLifeCycle = () => void

Expand All @@ -7,7 +7,8 @@ interface WeappComponent<P, S> extends Component<P, S> {
ready?: WeappLifeCycle
detached?: WeappLifeCycle
attached?: WeappLifeCycle
moved?: WeappLifeCycle
moved?: WeappLifeCycle,
globalData?: any,
setData: Function
}

Expand Down Expand Up @@ -54,6 +55,7 @@ export default function withWeapp (componentType: string) {
}

componentWillMount () {
this.globalData = Taro.getApp().globalData
this.executeComponentFunc(this.created)
this.safeExecute(super.componentWillMount)
}
Expand Down

0 comments on commit 2a387bf

Please sign in to comment.