feat: 2.x options support

This commit is contained in:
Evan You
2019-09-03 22:25:38 -04:00
parent c833db9c97
commit a6616e4210
6 changed files with 243 additions and 14 deletions

View File

@@ -12,7 +12,7 @@ import { capitalize } from '@vue/shared'
function injectHook(
type: LifecycleHooks,
hook: Function,
target: ComponentInstance | null = currentInstance
target: ComponentInstance | null
) {
if (target) {
;(target[type] || (target[type] = [])).push((...args: any[]) => {
@@ -26,7 +26,7 @@ function injectHook(
})
} else if (__DEV__) {
const apiName = `on${capitalize(
ErrorTypeStrings[name].replace(/ hook$/, '')
ErrorTypeStrings[type].replace(/ hook$/, '')
)}`
warn(
`${apiName} is called when there is no active component instance to be ` +