Skip to content

Commit 5953363

Browse files
Ryan P Kilbyyyx990803
authored andcommitted
Add Vue instance check & docs
1 parent f5c055c commit 5953363

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

docs/en/api/start.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ Start the router-enabled app. Creates an instance of `App` and mounts it to `el`
88

99
The `App` can be a Vue component constructor or a component options object. If it's an object, the router will implicitly call `Vue.extend` on it. This component will be used to create the root Vue instance for the app.
1010

11+
**Note:**
12+
vue-router cannot be started with Vue instances.
13+
1114
- `el: String|Element`
1215

1316
The element to mount the app on. Can be a CSS selector string or an actual element.

docs/en/basic.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ var Bar = Vue.extend({
3232
// The router needs a root component to render.
3333
// For demo purposes, we will just use an empty one
3434
// because we are using the HTML as the app template.
35+
// !! Note that the App is not a Vue instance.
3536
var App = Vue.extend({})
3637

3738
// Create a router instance.

src/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,12 @@ class Router {
244244
'root container.'
245245
)
246246
}
247+
if (App instanceof Vue) {
248+
throw new Error(
249+
'Must start vue-router with a component, not a ' +
250+
'Vue instance.'
251+
)
252+
}
247253
this._appContainer = container
248254
const Ctor = this._appConstructor = typeof App === 'function'
249255
? App

0 commit comments

Comments
 (0)