Comments (10)
But only is you have keepDefaultRouter enabled which I don't because I use the pages
folder for my custom Page that I don't want nuxt to treat as automatic route
from router-module.
Hi @mrleblanc101
It is already sent inside routerOptions
See https://github.com/nuxt-community/router-module#accessing-default-router
export function createRouter(ssrContext, createDefaultRouter, routerOptions, config) {
// https://github.com/nuxt/nuxt.js/blob/dev/packages/vue-app/template/router.js#L90-L95
// routerOptions.scrollBehavior <-- here
return new Router(routerOptions ? routerOptions : createDefaultRouter(ssrContext, config).options)
}
from router-module.
I will make sure that all options are passed and it is up to the user to decide what to do
from router-module.
@mrleblanc101
I added a new option parsePages
Waiting review
from router-module.
So something like ?
{
keepDefaultRouter: true,
parsePage: false
}
from router-module.
Yeap 😄
from router-module.
Does not look like it's working on my side using @nuxtjs/router: 1.6.1
.
If I use the above options, the page doesn't scroll to top.
{
keepDefaultRouter: true,
parsePages: false
}
But If I import from .nuxt/router.scrollBehavior.js
, it works:
import Vue from 'vue';
import Router from 'vue-router';
import scrollBehavior from '../.nuxt/router.scrollBehavior.js';
Vue.use(Router);
export function createRouter() {
return new Router({
base: '/',
mode: 'history',
scrollBehavior,
routes: [
...
],
});
}
from router-module.
Oh I think I get it.
I should've been using this: https://github.com/nuxt-community/router-module#accessing-default-router
I've been completely overwriting the router this whole time, which was "fine" since I have parsePages: false;
.
I thought the merging of both router was automatic.
export function createRouter(ssrContext, createDefaultRouter, routerOptions, config) {
const options = routerOptions ? routerOptions : createDefaultRouter(ssrContext, config).options
return new Router({
...options,
routes: fixRoutes(options.routes)
})
}
from router-module.
I must be doing something wrong because my 2nd and 3rd argument are null even if I have keepDefaultRouter: true;
[
{
req: IncomingMessage {
_readableState: [ReadableState],
_events: [Object: null prototype],
_eventsCount: 1,
_maxListeners: undefined,
socket: [Socket],
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: true,
headers: [Object],
rawHeaders: [Array],
trailers: {},
rawTrailers: [],
aborted: false,
upgrade: false,
url: '/repertoire/professionnels/1',
method: 'GET',
statusCode: null,
statusMessage: null,
client: [Socket],
_consuming: false,
_dumped: false,
originalUrl: '/repertoire/professionnels/1',
_parsedUrl: [Url],
_parsedOriginalUrl: [Url],
[Symbol(kCapture)]: false,
[Symbol(RequestTimeout)]: undefined
},
res: ServerResponse {
_events: [Object: null prototype],
_eventsCount: 1,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: false,
_last: false,
chunkedEncoding: false,
shouldKeepAlive: true,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: true,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: null,
_hasBody: true,
_trailer: '',
finished: false,
_headerSent: false,
socket: [Socket],
_header: null,
_keepAliveTimeout: 5000,
_onPendingData: [Function: bound updateOutgoingData],
_sent100: false,
_expect_continue: false,
locals: {},
statusCode: 200,
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: null
},
url: '/repertoire/professionnels/1',
target: 'server',
spa: undefined,
modern: false,
runtimeConfig: {
private: [Object],
public: [Object]
},
_registeredComponents: Set(0) {},
styles: [Getter],
_renderStyles: [Function: renderStyles],
_styles: {
'3e2078a7:0': [Object],
'92c0cd9c:0': [Object],
'0542ed34:0': [Object],
'778b9149:0': [Object],
'253dfc1e:0': [Object],
'ce243306:0': [Object],
'4d91c5a6:0': [Object],
'5d295e65:0': [Object],
'bd24c34c:0': [Object]
},
redirected: false,
next: [Function (anonymous)],
beforeRenderFns: [],
nuxt: {
layout: 'default',
data: [],
fetch: {},
error: null,
state: null,
serverRendered: true,
routePath: '',
config: [Object]
},
fetchCounters: {}
},
null,
null,
{
baseURL: 'localhost:3000',
apiURL: 'http://docs.campus-eeq.local.vici.io/api/client/v1',
_app: {
basePath: '/',
assetsPath: '/_nuxt/',
cdnURL: null
}
}
]
from router-module.
I was putting the options inside router
in my nuxt.config.json
instead of routerModule
🤦♂️
from router-module.
Related Issues (20)
- base route is appended to url on page referesh HOT 1
- next() function is not working well HOT 1
- children in route.js don't work HOT 2
- Custom router in .nuxt folder HOT 2
- does it support nuxt3 with vue3 HOT 3
- Vue router 4 support HOT 6
- Release HOT 1
- Cannot start nuxt: Cannot find module 'nuxt/lib/app/router' in nuxt3 HOT 5
- Readme "If you are using Nuxt < 2.16.0, the parameter store is not available" HOT 2
- the css load order changes after using @nuxtjs/router
- Cannot extend routes from a module
- Code splitting not working with router.js HOT 3
- `Cannot read properties of undefined (reading 'options')` on add @nuxtjs/router to Nuxt 3 project HOT 1
- Docs: Missing correct docs about the `store` parameter.
- Can I access to the routes within another module?
- Anchor link dont work on yarn generate
- Is this module compatible with SSG build?
- Nuxt 3 Support HOT 1
- Nuxt content not generate or parse to custom router
- Hydratation error with SSG HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from router-module.