Просмотр исходного кода

better template/render warning

Evan You 10 лет назад
Родитель
Сommit
887d037981
1 измененных файлов с 15 добавлено и 5 удалено
  1. 15 5
      src/runtime/instance/lifecycle.js

+ 15 - 5
src/runtime/instance/lifecycle.js

@@ -21,11 +21,21 @@ export function lifecycleMixin (Vue) {
   Vue.prototype.$mount = function (el) {
     if (!this.$options.render) {
       this.$options.render = () => this.$createElement('div')
-      process.env.NODE_ENV !== 'production' && warn(
-        'Failed to mount component: ' +
-        'template or render function not defined.',
-        this
-      )
+      if (process.env.NODE_ENV !== 'production') {
+        if (this.$options.template) {
+          warn(
+            'You are using the runtime-only build of Vue where the template ' +
+            'option is not available. Either pre-compile the templates into ' +
+            'render functions, or use the compiler-included build.',
+            this
+          )
+        } else {
+          warn(
+            'Failed to mount component: template or render function not defined.',
+            this
+          )
+        }
+      }
     }
     callHook(this, 'beforeMount')
     el = this.$el = el && query(el)