feat: log on the fly template compilation error
This commit is contained in:
parent
68f4e5e04d
commit
95d7e1f471
@ -319,7 +319,12 @@ function finishComponentSetup(
|
|||||||
if (Component.template && !Component.render) {
|
if (Component.template && !Component.render) {
|
||||||
if (compile) {
|
if (compile) {
|
||||||
Component.render = compile(Component.template, {
|
Component.render = compile(Component.template, {
|
||||||
onError(err) {}
|
onError(err) {
|
||||||
|
if (__DEV__) {
|
||||||
|
// TODO use err.loc to provide codeframe like Vue 2
|
||||||
|
warn(`Template compilation error: ${err.message}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
} else if (__DEV__) {
|
} else if (__DEV__) {
|
||||||
warn(
|
warn(
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
// This package is the "full-build" that includes both the runtime
|
// This package is the "full-build" that includes both the runtime
|
||||||
// and the compiler, and supports on-the-fly compilation of the template option.
|
// and the compiler, and supports on-the-fly compilation of the template option.
|
||||||
import { compile, CompilerOptions } from '@vue/compiler-dom'
|
import { compile, CompilerOptions } from '@vue/compiler-dom'
|
||||||
import * as runtimeDom from '@vue/runtime-dom'
|
|
||||||
import { registerRuntimeCompiler, RenderFunction } from '@vue/runtime-dom'
|
import { registerRuntimeCompiler, RenderFunction } from '@vue/runtime-dom'
|
||||||
|
import * as runtimeDom from '@vue/runtime-dom'
|
||||||
|
|
||||||
function compileToFunction(
|
function compileToFunction(
|
||||||
template: string,
|
template: string,
|
||||||
@ -12,6 +12,7 @@ function compileToFunction(
|
|||||||
hoistStatic: true,
|
hoistStatic: true,
|
||||||
...options
|
...options
|
||||||
})
|
})
|
||||||
|
|
||||||
return new Function('Vue', code)(runtimeDom) as RenderFunction
|
return new Function('Vue', code)(runtimeDom) as RenderFunction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user