Skip to content

Commit 3c78553

Browse files
committed
warn empty or missing template element (fix vuejs#4171)
1 parent 3e8ac27 commit 3c78553

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/core/instance/lifecycle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function lifecycleMixin (Vue: Class<Component>) {
4444
vm.$options.render = emptyVNode
4545
if (process.env.NODE_ENV !== 'production') {
4646
/* istanbul ignore if */
47-
if (vm.$options.template) {
47+
if (vm.$options.template && vm.$options.template.charAt(0) !== '#') {
4848
warn(
4949
'You are using the runtime-only build of Vue where the template ' +
5050
'option is not available. Either pre-compile the templates into ' +

src/entries/web-runtime-with-compiler.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ Vue.prototype.$mount = function (
3434
if (typeof template === 'string') {
3535
if (template.charAt(0) === '#') {
3636
template = idToTemplate(template)
37+
/* istanbul ignore if */
38+
if (process.env.NODE_ENV !== 'production' && !template) {
39+
warn(
40+
`Template element not found or is empty: ${options.template}`,
41+
this
42+
)
43+
}
3744
}
3845
} else if (template.nodeType) {
3946
template = template.innerHTML

0 commit comments

Comments
 (0)