diff --git a/src/history/base.js b/src/history/base.js index 5f2bad870..f96e4d9ce 100644 --- a/src/history/base.js +++ b/src/history/base.js @@ -146,7 +146,9 @@ export class History { cb(err) }) } else { - warn(false, 'uncaught error during route navigation:') + if (process.env.NODE_ENV !== 'production') { + warn(false, 'uncaught error during route navigation:') + } console.error(err) } } diff --git a/src/index.js b/src/index.js index 3cf38a496..4ffe2db57 100644 --- a/src/index.js +++ b/src/index.js @@ -39,6 +39,9 @@ export default class VueRouter { afterHooks: Array constructor (options: RouterOptions = {}) { + if (process.env.NODE_ENV !== 'production') { + warn(this instanceof VueRouter, `Router must be called with the new operator.`) + } this.app = null this.apps = [] this.options = options diff --git a/src/util/warn.js b/src/util/warn.js index 025d3b20f..95564c1a9 100644 --- a/src/util/warn.js +++ b/src/util/warn.js @@ -7,7 +7,7 @@ export function assert (condition: any, message: string) { } export function warn (condition: any, message: string) { - if (process.env.NODE_ENV !== 'production' && !condition) { + if (!condition) { typeof console !== 'undefined' && console.warn(`[vue-router] ${message}`) } }