lifecycle-parser.js 465 字节
Newer Older
fxy060608's avatar
fxy060608 已提交
1 2 3 4
import {
  hasOwn
} from 'uni-shared'

fxy060608's avatar
fxy060608 已提交
5 6 7 8
import {
  COMPONENT_LIFECYCLE,
  COMPONENT_LIFECYCLE_KEYS
} from '../constants'
fxy060608's avatar
fxy060608 已提交
9

fxy060608's avatar
fxy060608 已提交
10
export function parseLifecycle (mpComponentOptions, vueComponentOptions) {
fxy060608's avatar
fxy060608 已提交
11
  COMPONENT_LIFECYCLE_KEYS.forEach(name => {
fxy060608's avatar
fxy060608 已提交
12
    if (hasOwn(mpComponentOptions, name)) {
fxy060608's avatar
fxy060608 已提交
13 14
      (vueComponentOptions[COMPONENT_LIFECYCLE[name]] || (vueComponentOptions[COMPONENT_LIFECYCLE[name]] = []))
        .push(mpComponentOptions[name])
fxy060608's avatar
fxy060608 已提交
15
    }
fxy060608's avatar
fxy060608 已提交
16
  })
fxy060608's avatar
fxy060608 已提交
17
}