@mpxjs/core 2.7.52 → 2.8.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/@types/index.d.ts +342 -27
  2. package/package.json +10 -5
  3. package/src/convertor/convertor.js +2 -2
  4. package/src/convertor/mergeLifecycle.js +4 -4
  5. package/src/convertor/wxToAli.js +3 -4
  6. package/src/convertor/wxToSwan.js +2 -2
  7. package/src/convertor/wxToTt.js +1 -10
  8. package/src/convertor/wxToWeb.js +14 -7
  9. package/src/core/implement.js +2 -2
  10. package/src/core/injectMixins.js +1 -1
  11. package/src/core/innerLifecycle.js +15 -2
  12. package/src/core/mergeOptions.js +11 -5
  13. package/src/core/proxy.js +343 -229
  14. package/src/core/transferOptions.js +5 -2
  15. package/src/helper/const.js +10 -0
  16. package/src/index.js +73 -147
  17. package/src/observer/array.js +12 -17
  18. package/src/observer/computed.js +27 -56
  19. package/src/observer/dep.js +1 -1
  20. package/src/observer/effect.js +113 -0
  21. package/src/observer/effectScope.js +109 -0
  22. package/src/observer/{index.js → reactive.js} +74 -70
  23. package/src/observer/ref.js +97 -0
  24. package/src/observer/scheduler.js +171 -56
  25. package/src/observer/watch.js +163 -39
  26. package/src/platform/builtInMixins/i18nMixin.js +238 -31
  27. package/src/platform/builtInMixins/pageScrollMixin.web.js +4 -5
  28. package/src/platform/builtInMixins/pageStatusMixin.js +76 -54
  29. package/src/platform/builtInMixins/pageStatusMixin.web.js +35 -22
  30. package/src/platform/builtInMixins/proxyEventMixin.js +40 -22
  31. package/src/platform/builtInMixins/proxyEventMixin.web.js +16 -24
  32. package/src/platform/builtInMixins/refsMixin.js +82 -73
  33. package/src/platform/builtInMixins/refsMixin.web.js +0 -47
  34. package/src/platform/builtInMixins/relationsMixin.js +10 -9
  35. package/src/platform/builtInMixins/renderHelperMixin.js +1 -1
  36. package/src/platform/builtInMixins/showMixin.js +1 -1
  37. package/src/platform/createApp.js +5 -5
  38. package/src/platform/export/api.js +23 -0
  39. package/src/platform/export/api.web.js +26 -0
  40. package/src/platform/export/index.js +45 -0
  41. package/src/platform/export/index.web.js +36 -0
  42. package/src/platform/index.js +1 -5
  43. package/src/platform/patch/ali/getDefaultOptions.js +33 -31
  44. package/src/platform/patch/ali/lifecycle.js +21 -13
  45. package/src/platform/patch/builtInKeysMap.js +2 -1
  46. package/src/platform/patch/index.js +4 -9
  47. package/src/platform/patch/swan/getDefaultOptions.js +3 -3
  48. package/src/platform/patch/swan/lifecycle.js +17 -14
  49. package/src/platform/patch/web/getDefaultOptions.js +40 -16
  50. package/src/platform/patch/web/lifecycle.js +6 -3
  51. package/src/platform/patch/wx/getDefaultOptions.js +38 -31
  52. package/src/platform/patch/wx/lifecycle.js +18 -11
  53. package/src/runtime/createFactory.js +6 -2
  54. package/src/vue.web.js +3 -0
  55. package/src/vuePlugin.js +31 -0
  56. package/src/core/createStore.js +0 -241
  57. package/src/core/mapStore.js +0 -94
  58. package/src/helper/env.js +0 -20
  59. package/src/helper/getByPath.js +0 -127
  60. package/src/helper/log.js +0 -31
  61. package/src/helper/utils.js +0 -652
  62. package/src/observer/watcher.js +0 -244
@@ -0,0 +1,26 @@
1
+ import Vue from '../../vue'
2
+ import { injectMixins } from '../../core/injectMixins'
3
+
4
+ function initApi () {
5
+ const vm = new Vue()
6
+ const observable = Vue.observable.bind(Vue)
7
+ const watch = vm.$watch.bind(vm)
8
+ const set = Vue.set.bind(Vue)
9
+ const del = Vue.delete.bind(Vue)
10
+ APIs = {
11
+ injectMixins,
12
+ mixin: injectMixins,
13
+ observable,
14
+ watch,
15
+ // use,
16
+ set,
17
+ delete: del
18
+ }
19
+ return APIs
20
+ }
21
+ let APIs = initApi()
22
+ const InstanceAPIs = {}
23
+ export {
24
+ APIs,
25
+ InstanceAPIs
26
+ }
@@ -0,0 +1,45 @@
1
+
2
+ export {
3
+ watchEffect,
4
+ watchSyncEffect,
5
+ watchPostEffect,
6
+ watch
7
+ } from '../../observer/watch'
8
+
9
+ export {
10
+ reactive,
11
+ isReactive,
12
+ shallowReactive,
13
+ set,
14
+ del,
15
+ markRaw
16
+ } from '../../observer/reactive'
17
+
18
+ export {
19
+ ref,
20
+ unref,
21
+ toRef,
22
+ toRefs,
23
+ isRef,
24
+ customRef,
25
+ shallowRef,
26
+ triggerRef
27
+ } from '../../observer/ref'
28
+
29
+ export {
30
+ computed
31
+ } from '../../observer/computed'
32
+
33
+ export {
34
+ effectScope,
35
+ getCurrentScope,
36
+ onScopeDispose
37
+ } from '../../observer/effectScope'
38
+
39
+ export {
40
+ getCurrentInstance
41
+ } from '../../core/proxy'
42
+
43
+ export {
44
+ useI18n
45
+ } from '../../platform/builtInMixins/i18nMixin'
@@ -0,0 +1,36 @@
1
+ export {
2
+ // watch
3
+ watchEffect,
4
+ watchSyncEffect,
5
+ watchPostEffect,
6
+ watch,
7
+ // reactive
8
+ reactive,
9
+ isReactive,
10
+ shallowReactive,
11
+ set,
12
+ del,
13
+ markRaw,
14
+ // ref
15
+ ref,
16
+ unref,
17
+ toRef,
18
+ toRefs,
19
+ isRef,
20
+ customRef,
21
+ shallowRef,
22
+ triggerRef,
23
+ // computed
24
+ computed,
25
+ // effectScope
26
+ effectScope,
27
+ getCurrentScope,
28
+ onScopeDispose,
29
+ // instance
30
+ getCurrentInstance
31
+ } from 'vue'
32
+
33
+ export {
34
+ // i18n
35
+ useI18n
36
+ } from 'vue-i18n-bridge'
@@ -2,8 +2,4 @@ import createApp from './createApp'
2
2
  import createPage from './createPage'
3
3
  import createComponent from './createComponent'
4
4
 
5
- export {
6
- createApp,
7
- createPage,
8
- createComponent
9
- }
5
+ export { createApp, createPage, createComponent }
@@ -1,8 +1,7 @@
1
- import MPXProxy from '../../../core/proxy'
1
+ import MpxProxy from '../../../core/proxy'
2
2
  import builtInKeysMap from '../builtInKeysMap'
3
3
  import mergeOptions from '../../../core/mergeOptions'
4
- import { error } from '../../../helper/log'
5
- import { diffAndCloneA, hasOwn } from '../../../helper/utils'
4
+ import { isFunction, error, diffAndCloneA, hasOwn } from '@mpxjs/utils'
6
5
 
7
6
  function transformApiForProxy (context, currentInject) {
8
7
  const rawSetData = context.setData.bind(context)
@@ -17,20 +16,23 @@ function transformApiForProxy (context, currentInject) {
17
16
  })
18
17
  }
19
18
  Object.defineProperties(context, {
20
- __getInitialData: {
19
+ __getProps: {
21
20
  get () {
22
21
  return (options) => {
22
+ const props = {}
23
+ const validProps = Object.assign({}, options.properties, options.props)
23
24
  if (context.props) {
24
- const newData = context.$rawOptions.__nativeRender__ ? context.data : Object.assign({}, context.data)
25
- const validProps = Object.assign({}, options.props, options.properties)
26
25
  Object.keys(context.props).forEach((key) => {
27
- if (hasOwn(validProps, key) && typeof context.props[key] !== 'function') {
28
- newData[key] = context.props[key]
26
+ if (hasOwn(validProps, key) && !isFunction(context.props[key])) {
27
+ props[key] = context.props[key]
29
28
  }
30
29
  })
31
- return newData
32
30
  }
33
- return context.data
31
+ if (options.__nativeRender__) {
32
+ // 微信原生转支付宝时,首次将非函数props数据合入data中
33
+ Object.assign(context.data, props)
34
+ }
35
+ return props
34
36
  }
35
37
  },
36
38
  configurable: false
@@ -83,30 +85,37 @@ function filterOptions (options, type) {
83
85
  return newOptions
84
86
  }
85
87
 
86
- function initProxy (context, rawOptions, currentInject, params) {
88
+ function initProxy (context, rawOptions, currentInject) {
87
89
  if (!context.__mpxProxy) {
88
90
  // 提供代理对象需要的api
89
91
  transformApiForProxy(context, currentInject)
90
- // 缓存options
91
- context.$rawOptions = rawOptions
92
92
  // 创建proxy对象
93
- context.__mpxProxy = new MPXProxy(rawOptions, context)
94
- context.__mpxProxy.created(params)
95
- } else if (context.__mpxProxy.isDestroyed()) {
96
- context.__mpxProxy.reCreated(params)
93
+ context.__mpxProxy = new MpxProxy(rawOptions, context)
94
+ context.__mpxProxy.created()
95
+ } else if (context.__mpxProxy.isUnmounted()) {
96
+ context.__mpxProxy = new MpxProxy(rawOptions, context, true)
97
+ context.__mpxProxy.created()
97
98
  }
98
99
  }
99
100
 
100
101
  export function getDefaultOptions (type, { rawOptions = {}, currentInject }) {
101
102
  const hookNames = type === 'component' ? ['onInit', 'didMount', 'didUnmount'] : ['onLoad', 'onReady', 'onUnload']
102
103
  const rootMixins = [{
103
- [hookNames[0]] (...params) {
104
- initProxy(this, rawOptions, currentInject, params)
104
+ [hookNames[0]] () {
105
+ if (rawOptions.__nativeRender__ && this.props) {
106
+ const validProps = Object.assign({}, rawOptions.props, rawOptions.properties)
107
+ Object.keys(this.props).forEach((key) => {
108
+ if (hasOwn(validProps, key) && typeof this.props[key] !== 'function') {
109
+ this.data[key] = this.props[key]
110
+ }
111
+ })
112
+ }
113
+ initProxy(this, rawOptions, currentInject)
105
114
  },
106
115
  deriveDataFromProps (nextProps) {
107
116
  if (this.__mpxProxy && this.__mpxProxy.isMounted() && nextProps && nextProps !== this.props) {
108
- const validProps = Object.assign({}, this.$rawOptions.props, this.$rawOptions.properties)
109
- if (this.$rawOptions.__nativeRender__) {
117
+ const validProps = Object.assign({}, rawOptions.props, rawOptions.properties)
118
+ if (rawOptions.__nativeRender__) {
110
119
  const newData = {}
111
120
  // 微信原生转换支付宝时,每次props更新将其设置进data模拟微信表现
112
121
  Object.keys(nextProps).forEach((key) => {
@@ -122,21 +131,14 @@ export function getDefaultOptions (type, { rawOptions = {}, currentInject }) {
122
131
  Object.keys(nextProps).forEach(key => {
123
132
  if (hasOwn(validProps, key) && typeof nextProps[key] !== 'function') {
124
133
  const { diff, clone } = diffAndCloneA(nextProps[key], this.props[key])
125
- // 由于支付宝中透传父级setData的值,此处进行深copy后赋值避免父级存储的miniRenderData部分数据在此处被响应化,在子组件对props赋值时触发父组件的render
134
+ // 由于支付宝中透传父级setData的值,此处进行深clone后赋值避免父级存储的miniRenderData部分数据在此处被响应化,在子组件对props赋值时触发父组件的render
126
135
  if (diff) this[key] = clone
127
136
  }
128
137
  })
138
+ this.__mpxProxy.propsUpdated()
129
139
  }
130
140
  }
131
141
  },
132
- didUpdate () {
133
- if (this.__mpxProxy) {
134
- // todo: lockTask必要性待验证,属性更新触发自身setData时,updated执行与wx对齐,updated触发机制也考虑与wx对齐(props update && setData callback)
135
- this.__mpxProxy.lockTask(() => {
136
- this.__mpxProxy.updated()
137
- })
138
- }
139
- },
140
142
  [hookNames[1]] () {
141
143
  if (this.__mpxProxy) {
142
144
  this.__mpxProxy.mounted()
@@ -145,7 +147,7 @@ export function getDefaultOptions (type, { rawOptions = {}, currentInject }) {
145
147
  }
146
148
  },
147
149
  [hookNames[2]] () {
148
- if (this.__mpxProxy) this.__mpxProxy.destroyed()
150
+ if (this.__mpxProxy) this.__mpxProxy.unmounted()
149
151
  }
150
152
  }]
151
153
  rawOptions.mixins = rawOptions.mixins ? rootMixins.concat(rawOptions.mixins) : rootMixins
@@ -1,4 +1,12 @@
1
- import { BEFORECREATE, BEFOREMOUNT, CREATED, DESTROYED, MOUNTED, UPDATED } from '../../../core/innerLifecycle'
1
+ import {
2
+ CREATED,
3
+ UNMOUNTED,
4
+ MOUNTED,
5
+ ONHIDE,
6
+ ONSHOW,
7
+ ONLOAD,
8
+ UPDATED
9
+ } from '../../../core/innerLifecycle'
2
10
 
3
11
  const APP_HOOKS = [
4
12
  'onLaunch',
@@ -6,7 +14,8 @@ const APP_HOOKS = [
6
14
  'onHide',
7
15
  'onError',
8
16
  'onShareAppMessage',
9
- 'onUnhandledRejection'
17
+ 'onUnhandledRejection',
18
+ 'onPageNotFound'
10
19
  ]
11
20
 
12
21
  const PAGE_HOOKS = [
@@ -15,14 +24,13 @@ const PAGE_HOOKS = [
15
24
  'onShow',
16
25
  'onHide',
17
26
  'onUnload',
18
- 'onPullDownRefresh',
19
- 'onReachBottom',
20
27
  'onShareAppMessage',
21
- 'onPageScroll',
22
28
  'onTitleClick',
23
29
  'onOptionMenuClick',
24
- 'onUpdated',
25
- 'onBeforeCreate'
30
+ 'onPullDownRefresh',
31
+ 'onTabItemTap',
32
+ 'onPageScroll',
33
+ 'onReachBottom'
26
34
  ]
27
35
 
28
36
  const COMPONENT_HOOKS = [
@@ -31,19 +39,19 @@ const COMPONENT_HOOKS = [
31
39
  'didMount',
32
40
  'didUpdate',
33
41
  'didUnmount',
34
- 'updated',
35
- 'beforeCreate',
42
+ 'onError',
36
43
  'pageShow',
37
44
  'pageHide'
38
45
  ]
39
46
 
40
47
  export const lifecycleProxyMap = {
41
- [BEFORECREATE]: ['beforeCreate'],
42
48
  [CREATED]: ['onInit'],
43
- [UPDATED]: ['didUpdate', 'updated'],
44
- [BEFOREMOUNT]: ['beforeMount'],
49
+ [UPDATED]: ['didUpdate'],
45
50
  [MOUNTED]: ['didMount', 'onReady'],
46
- [DESTROYED]: ['didUnmount', 'onUnload']
51
+ [UNMOUNTED]: ['didUnmount', 'onUnload'],
52
+ [ONSHOW]: ['pageShow', 'onShow'],
53
+ [ONHIDE]: ['pageHide', 'onHide'],
54
+ [ONLOAD]: ['onLoad']
47
55
  }
48
56
 
49
57
  export const LIFECYCLE = {
@@ -1,5 +1,5 @@
1
1
  import { INNER_LIFECYCLES } from '../../core/innerLifecycle'
2
- import { makeMap } from '../../helper/utils'
2
+ import { makeMap } from '@mpxjs/utils'
3
3
 
4
4
  let bulitInKeys
5
5
 
@@ -16,6 +16,7 @@ if (__mpx_mode__ === 'web') {
16
16
  ]
17
17
  } else {
18
18
  bulitInKeys = [
19
+ 'setup',
19
20
  'dataFn',
20
21
  'proto',
21
22
  'mixins',
@@ -4,7 +4,7 @@ import { getDefaultOptions as getWxDefaultOptions } from './wx/getDefaultOptions
4
4
  import { getDefaultOptions as getAliDefaultOptions } from './ali/getDefaultOptions'
5
5
  import { getDefaultOptions as getSwanDefaultOptions } from './swan/getDefaultOptions'
6
6
  import { getDefaultOptions as getWebDefaultOptions } from './web/getDefaultOptions'
7
- import { error } from '../../helper/log'
7
+ import { error } from '@mpxjs/utils'
8
8
 
9
9
  export default function createFactory (type) {
10
10
  return (options, { isNative, customCtor, customCtorType } = {}) => {
@@ -49,7 +49,10 @@ export default function createFactory (type) {
49
49
  getDefaultOptions = getWxDefaultOptions
50
50
  }
51
51
 
52
+ const { setup } = options
52
53
  const { rawOptions, currentInject } = transferOptions(options, type)
54
+ rawOptions.setup = setup
55
+ // 不接受mixin中的setup配置
53
56
  // 注入内建的mixins, 内建mixin是按原始平台编写的,所以合并规则和rootMixins保持一致
54
57
  // 将合并后的用户定义的rawOptions传入获取当前应该注入的内建mixins
55
58
  rawOptions.mixins = getBuiltInMixins(rawOptions, type)
@@ -62,11 +65,3 @@ export default function createFactory (type) {
62
65
  }
63
66
  }
64
67
  }
65
-
66
- export function getRenderCallBack (context) {
67
- return () => {
68
- if (__mpx_mode__ !== 'ali' || context.options.__type__ === 'page') {
69
- context.updated()
70
- }
71
- }
72
- }
@@ -9,14 +9,14 @@ export function getDefaultOptions (type, { rawOptions = {}, currentInject }) {
9
9
  }
10
10
 
11
11
  const rootMixin = {
12
- [hookNames[0]] (...params) {
13
- initProxy(this, rawOptions, currentInject, params)
12
+ [hookNames[0]] () {
13
+ initProxy(this, rawOptions, currentInject)
14
14
  },
15
15
  [hookNames[1]] () {
16
16
  if (this.__mpxProxy) this.__mpxProxy.mounted()
17
17
  },
18
18
  [hookNames[2]] () {
19
- if (this.__mpxProxy) this.__mpxProxy.destroyed()
19
+ if (this.__mpxProxy) this.__mpxProxy.unmounted()
20
20
  }
21
21
  }
22
22
 
@@ -1,13 +1,19 @@
1
- import { BEFORECREATE, CREATED, DESTROYED, MOUNTED, UPDATED, BEFOREMOUNT } from '../../../core/innerLifecycle'
1
+ import {
2
+ CREATED,
3
+ UNMOUNTED,
4
+ MOUNTED,
5
+ ONSHOW,
6
+ ONHIDE,
7
+ ONLOAD
8
+ } from '../../../core/innerLifecycle'
2
9
 
3
10
  const APP_HOOKS = [
11
+ 'onLogin',
4
12
  'onLaunch',
5
13
  'onShow',
6
14
  'onHide',
7
15
  'onError',
8
- 'onPageNotFound',
9
- 'onUnhandledRejection',
10
- 'onThemeChange'
16
+ 'onPageNotFound'
11
17
  ]
12
18
 
13
19
  const PAGE_HOOKS = [
@@ -19,32 +25,29 @@ const PAGE_HOOKS = [
19
25
  'onUnload',
20
26
  'onPullDownRefresh',
21
27
  'onReachBottom',
22
- 'onShareAppMessage',
23
28
  'onPageScroll',
29
+ 'onShareAppMessage',
24
30
  'onTabItemTap',
31
+ 'onURLQueryChange',
25
32
  'onResize'
26
33
  ]
27
34
 
28
35
  const COMPONENT_HOOKS = [
29
- 'beforeCreate',
30
36
  'created',
31
37
  'attached',
32
38
  'ready',
33
- 'moved',
34
39
  'detached',
35
- 'updated',
36
40
  'pageShow',
37
- 'pageHide',
38
- 'definitionFilter'
41
+ 'pageHide'
39
42
  ]
40
43
 
41
44
  export const lifecycleProxyMap = {
42
- [BEFORECREATE]: ['beforeCreate'],
43
45
  [CREATED]: ['onInit', 'created', 'attached'],
44
- [UPDATED]: ['updated'],
45
- [BEFOREMOUNT]: ['beforeMount'],
46
46
  [MOUNTED]: ['ready', 'onReady'],
47
- [DESTROYED]: ['detached', 'onUnload']
47
+ [UNMOUNTED]: ['detached', 'onUnload'],
48
+ [ONSHOW]: ['pageShow', 'onShow'],
49
+ [ONHIDE]: ['pageHide', 'onHide'],
50
+ [ONLOAD]: ['onLoad']
48
51
  }
49
52
 
50
53
  export const LIFECYCLE = {
@@ -1,7 +1,9 @@
1
1
  import builtInKeysMap from '../builtInKeysMap'
2
2
  import mergeOptions from '../../../core/mergeOptions'
3
- import MPXProxy from '../../../core/proxy'
4
- import { diffAndCloneA } from '../../../helper/utils'
3
+ import { diffAndCloneA } from '@mpxjs/utils'
4
+ import { getCurrentInstance as getVueCurrentInstance } from '../../export/index'
5
+ import MpxProxy, { setCurrentInstance, unsetCurrentInstance } from '../../../core/proxy'
6
+ import { BEFOREUPDATE, UPDATED, BEFOREUNMOUNT, UNMOUNTED } from '../../../core/innerLifecycle'
5
7
 
6
8
  function filterOptions (options) {
7
9
  const newOptions = {}
@@ -23,34 +25,56 @@ function filterOptions (options) {
23
25
  return newOptions
24
26
  }
25
27
 
26
- function initProxy (context, rawOptions, params) {
28
+ function initProxy (context, rawOptions) {
27
29
  if (!context.__mpxProxy) {
28
- // 缓存options
29
- context.$rawOptions = rawOptions
30
- // 创建proxy对象
31
- context.__mpxProxy = new MPXProxy(rawOptions, context)
32
- context.__mpxProxy.created(params)
33
- } else if (context.__mpxProxy.isDestroyed()) {
34
- context.__mpxProxy.reCreated(params)
30
+ context.__mpxProxy = new MpxProxy(rawOptions, context)
31
+ } else if (context.__mpxProxy.isUnmounted()) {
32
+ context.__mpxProxy = new MpxProxy(rawOptions, context, true)
35
33
  }
36
34
  }
37
35
 
38
36
  export function getDefaultOptions (type, { rawOptions = {} }) {
37
+ const rawSetup = rawOptions.setup
38
+ if (rawSetup) {
39
+ rawOptions.setup = (props) => {
40
+ const instance = getVueCurrentInstance().proxy
41
+ initProxy(instance, rawOptions)
42
+ setCurrentInstance(instance.__mpxProxy)
43
+ const newContext = {
44
+ triggerEvent: instance.triggerEvent.bind(instance),
45
+ refs: instance.$refs,
46
+ forceUpdate: instance.$forceUpdate.bind(instance),
47
+ selectComponent: instance.selectComponent.bind(instance),
48
+ selectAllComponents: instance.selectAllComponents.bind(instance),
49
+ createSelectorQuery: instance.createSelectorQuery.bind(instance),
50
+ createIntersectionObserver: instance.createIntersectionObserver.bind(instance)
51
+ }
52
+ const setupRes = rawSetup(props, newContext)
53
+ unsetCurrentInstance(instance.__mpxProxy)
54
+ return setupRes
55
+ }
56
+ }
39
57
  const rootMixins = [{
58
+ beforeCreate () {
59
+ initProxy(this, rawOptions)
60
+ },
40
61
  created () {
41
- const query = (global.__mpxRouter && global.__mpxRouter.currentRoute && global.__mpxRouter.currentRoute.query) || {}
42
- initProxy(this, rawOptions, [query])
43
- // web中单独触发onLoad
44
- this.onLoad && this.onLoad(query)
62
+ if (this.__mpxProxy) this.__mpxProxy.created()
45
63
  },
46
64
  mounted () {
47
65
  if (this.__mpxProxy) this.__mpxProxy.mounted()
48
66
  },
67
+ beforeUpdate () {
68
+ if (this.__mpxProxy) this.__mpxProxy.callHook(BEFOREUPDATE)
69
+ },
49
70
  updated () {
50
- if (this.__mpxProxy) this.__mpxProxy.updated()
71
+ if (this.__mpxProxy) this.__mpxProxy.callHook(UPDATED)
72
+ },
73
+ beforeDestroy () {
74
+ if (this.__mpxProxy) this.__mpxProxy.callHook(BEFOREUNMOUNT)
51
75
  },
52
76
  destroyed () {
53
- if (this.__mpxProxy) this.__mpxProxy.destroyed()
77
+ if (this.__mpxProxy) this.__mpxProxy.callHook(UNMOUNTED)
54
78
  }
55
79
  }]
56
80
  // 为了在builtMixin中可以使用某些rootMixin实现的特性(如数据响应等),此处builtInMixin在rootMixin之后执行,但是当builtInMixin使用存在对应内建生命周期的目标平台声明周期写法时,可能会出现用户生命周期比builtInMixin中的生命周期先执行的情况,为了避免这种情况发生,builtInMixin应该尽可能使用内建生命周期来编写
@@ -9,8 +9,7 @@ const COMPONENT_HOOKS = [
9
9
  'deactivated',
10
10
  'beforeDestroy',
11
11
  'destroyed',
12
- 'errorCaptured',
13
- 'onPageNotFound'
12
+ 'errorCaptured'
14
13
  ]
15
14
 
16
15
  const PAGE_HOOKS = [
@@ -23,8 +22,12 @@ const PAGE_HOOKS = [
23
22
  'onPullDownRefresh',
24
23
  'onReachBottom',
25
24
  'onPageScroll',
25
+ 'onAddToFavorites',
26
+ 'onShareAppMessage',
27
+ 'onShareTimeline',
28
+ 'onResize',
26
29
  'onTabItemTap',
27
- 'onResize'
30
+ 'onSaveExitState'
28
31
  ]
29
32
 
30
33
  const APP_HOOKS = [