Skip to content

Commit ae47ca6

Browse files
committed
Fix some issues with the router.
1 parent f3fa556 commit ae47ca6

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

generator/templates/simple/src/main.native.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@ import Navigator from 'nativescript-vue-navigator'
1818
import App from './App.vue';
1919
import { options } from './router';
2020

21-
Vue.use(Navigator, { routes: options.routes })
21+
const routes = options.routes.reduce((data, route) => {
22+
data[route.name] = {
23+
component: route.component
24+
}
25+
return data
26+
}, {});
27+
28+
Vue.use(Navigator, { routes });
2229
<%# END_REPLACE %>
2330

2431
<%# REPLACE %>

generator/templates/simple/src/router.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ replace:
55
- !!js/regexp /import Router from 'vue-router'/
66
- !!js/regexp /Vue.use\(Router\)/
77
- !!js/regexp /export default new Router\(\{/
8-
- !!js/regexp /import Home from './views/Home.vue'/
9-
- !!js/regexp /'./views/About.vue'\)/
8+
- !!js/regexp /import Home from '\./views/Home.vue'/
9+
- !!js/regexp /\(\) => import(.*)\.\/views\/About\.vue'\)/
10+
- !!js/regexp /(\s+)\/\/ (.*)/
11+
- !!js/regexp /(\s+)\/\/ (.*)/
12+
- !!js/regexp /(\s+)\/\/ (.*)/
1013
- !!js/regexp /\}\)/
1114
---
1215

@@ -28,10 +31,20 @@ export const options = {
2831

2932
<%# REPLACE %>
3033
import Home from '~/views/Home.vue';
34+
import About from '~/views/About.vue';
35+
<%# END_REPLACE %>
36+
37+
<%# REPLACE %>
38+
About,
39+
<%# END_REPLACE %>
40+
41+
<%# REPLACE %>
42+
<%# END_REPLACE %>
43+
44+
<%# REPLACE %>
3145
<%# END_REPLACE %>
3246

3347
<%# REPLACE %>
34-
'~/views/About.vue'),
3548
<%# END_REPLACE %>
3649

3750
<%# REPLACE %>

0 commit comments

Comments
 (0)