Skip to content

Commit 2ad6bf2

Browse files
ricardogobbosouzapi0
authored andcommitted
feat(vue-app): export router options (nuxt#6231)
1 parent 35ba655 commit 2ad6bf2

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

packages/vue-app/template/router.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,20 @@ const _routes = recursiveRoutes(router.routes, ' ', _components, 2)
8484

8585
Vue.use(Router)
8686

87+
export const routerOptions = {
88+
mode: '<%= router.mode %>',
89+
base: decodeURI('<%= router.base %>'),
90+
linkActiveClass: '<%= router.linkActiveClass %>',
91+
linkExactActiveClass: '<%= router.linkExactActiveClass %>',
92+
scrollBehavior,
93+
<%= isTest ? '/* eslint-disable quotes, object-curly-spacing, key-spacing */' : '' %>
94+
routes: [<%= _routes %>],
95+
<%= isTest ? '/* eslint-enable quotes, object-curly-spacing, key-spacing */' : '' %>
96+
<% if (router.parseQuery) { %>parseQuery: <%= serializeFunction(router.parseQuery) %>,<% } %>
97+
<% if (router.stringifyQuery) { %>stringifyQuery: <%= serializeFunction(router.stringifyQuery) %>,<% } %>
98+
fallback: <%= router.fallback %>
99+
}
100+
87101
export function createRouter() {
88-
return new Router({
89-
mode: '<%= router.mode %>',
90-
base: decodeURI('<%= router.base %>'),
91-
linkActiveClass: '<%= router.linkActiveClass %>',
92-
linkExactActiveClass: '<%= router.linkExactActiveClass %>',
93-
scrollBehavior,
94-
<%= isTest ? '/* eslint-disable quotes, object-curly-spacing, key-spacing */' : '' %>
95-
routes: [<%= _routes %>],
96-
<%= isTest ? '/* eslint-enable quotes, object-curly-spacing, key-spacing */' : '' %>
97-
<% if (router.parseQuery) { %>parseQuery: <%= serializeFunction(router.parseQuery) %>,<% } %>
98-
<% if (router.stringifyQuery) { %>stringifyQuery: <%= serializeFunction(router.stringifyQuery) %>,<% } %>
99-
fallback: <%= router.fallback %>
100-
})
102+
return new Router(routerOptions)
101103
}

0 commit comments

Comments
 (0)