Router Middleware

在此示例中:

store/class.js sets a class to the body.

middleware/class.js uses router middleware to set a class before we enter the route.

components/Navigation.vue changes the font size for the route with the name of router-middleware.

nuxt.config.js contains the router property to activate the middleware.

Learn more in the Directory Structure book in the middleware chapter.

Loading CodeSandbox...