fix(inject): fix support for inject option default function

fix #2050
This commit is contained in:
Evan You
2020-09-04 12:00:37 -04:00
parent 6dbc6c4cd0
commit d4724619fc
3 changed files with 47 additions and 42 deletions

View File

@@ -457,7 +457,11 @@ export function applyOptions(
for (const key in injectOptions) {
const opt = injectOptions[key]
if (isObject(opt)) {
ctx[key] = inject(opt.from, opt.default)
ctx[key] = inject(
opt.from,
opt.default,
true /* treat default function as factory */
)
} else {
ctx[key] = inject(opt)
}