File tree 2 files changed +13
-4
lines changed
packages/@vue/cli-plugin-router/generator
2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ module.exports = (api, options = {}) => {
10
10
11
11
api . render ( './template' , {
12
12
historyMode : options . historyMode ,
13
- doesCompile : api . hasPlugin ( 'babel' ) || api . hasPlugin ( 'typescript' )
13
+ doesCompile : api . hasPlugin ( 'babel' ) || api . hasPlugin ( 'typescript' ) ,
14
+ hasTypeScript : api . hasPlugin ( 'typescript' )
14
15
} )
15
16
16
17
if ( api . invoking ) {
Original file line number Diff line number Diff line change 1
1
import Vue from 'vue'
2
+ < % _ if ( hasTypeScript ) { _ % >
3
+ import VueRouter , { RouteConfig } from 'vue-router'
4
+ < % _ } else { _ % >
2
5
import VueRouter from 'vue-router'
6
+ < % _ } _ % >
3
7
import Home from '../views/Home.vue'
4
8
5
- Vue . use ( VueRouter )
6
-
7
- const routes = [
9
+ < % _ if ( hasTypeScript ) { _ % >
10
+ const routes = < Array < RouteConfig > > [
11
+ < % _ } else { _ % >
12
+ const routes = [
13
+ < % _ } _ % >
8
14
{
9
15
path : '/' ,
10
16
name : 'home' ,
@@ -26,6 +32,8 @@ const routes = [
26
32
}
27
33
]
28
34
35
+ Vue . use ( VueRouter )
36
+
29
37
const router = new VueRouter ( {
30
38
< % _ if ( historyMode ) { _ % >
31
39
mode : 'history' ,
You can’t perform that action at this time.
0 commit comments