index.ts 626 字节
Newer Older
fxy060608's avatar
fxy060608 已提交
1
import { App } from 'vue'
fxy060608's avatar
fxy060608 已提交
2 3 4 5

import { isFunction } from '@vue/shared'

import { applyOptions } from './componentOptions'
fxy060608's avatar
fxy060608 已提交
6
import { set } from './componentInstance'
fxy060608's avatar
fxy060608 已提交
7
import { errorHandler } from './appConfig'
雪洛's avatar
雪洛 已提交
8 9
import { uniIdMixin } from './uni-id-mixin'

fxy060608's avatar
fxy060608 已提交
10 11 12 13 14 15
export function initApp(app: App) {
  const appConfig = app._context.config
  if (isFunction((app._component as any).onError)) {
    appConfig.errorHandler = errorHandler
  }
  const globalProperties = appConfig.globalProperties
雪洛's avatar
雪洛 已提交
16
  uniIdMixin(globalProperties)
fxy060608's avatar
fxy060608 已提交
17 18 19 20 21
  if (__VUE_OPTIONS_API__) {
    globalProperties.$set = set
    globalProperties.$applyOptions = applyOptions
  }
}