lifecycle-parser.js 494 字节
Newer Older
fxy060608's avatar
fxy060608 已提交
1 2 3 4 5 6 7 8 9 10 11 12
import {
  hasOwn
} from 'uni-shared'

const LIFECYCLE = {
  'created': 'created',
  'attached': 'created',
  'ready': 'mounted',
  'moved': 'moved',
  'detached': 'destroyed'
}
const LIFECYCLE_KEYS = Object.keys(LIFECYCLE)
fxy060608's avatar
fxy060608 已提交
13

fxy060608's avatar
fxy060608 已提交
14 15 16 17 18 19
export function parseLifecycle (mpComponentOptions, vueComponentOptions) {
  Object.keys(LIFECYCLE_KEYS).forEach(name => {
    if (hasOwn(mpComponentOptions, name)) {
      vueComponentOptions[LIFECYCLE[name]] = mpComponentOptions[name]
    }
  })
fxy060608's avatar
fxy060608 已提交
20
}