Skip to content

Commit fb49a03

Browse files
committed
make router loadable in node
1 parent dde6b3b commit fb49a03

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Router.install = function (Vue) {
2323

2424
// auto install
2525
/* istanbul ignore if */
26-
if (window.Vue) {
26+
if (typeof window !== 'undefined' && window.Vue) {
2727
Router.install(window.Vue)
2828
}
2929

src/router/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
var util = require('../util')
12
var Recognizer = require('route-recognizer')
23
var historyBackends = {
34
abstract: require('../history/abstract'),
@@ -64,7 +65,8 @@ function Router (options) {
6465
this._suppress = !!options.suppressTransitionError
6566

6667
// create history object
67-
this.mode = this._abstract
68+
var inBrowser = util.Vue.util.inBrowser
69+
this.mode = (!inBrowser || this._abstract)
6870
? 'abstract'
6971
: this._history
7072
? 'html5'

0 commit comments

Comments
 (0)