Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useFileSystemPublicRoutes 的作用是什么? #7

Open
dailynodejs opened this issue Sep 14, 2020 · 0 comments
Open

useFileSystemPublicRoutes 的作用是什么? #7

dailynodejs opened this issue Sep 14, 2020 · 0 comments

Comments

@dailynodejs
Copy link
Collaborator

dailynodejs commented Sep 14, 2020

用途是什么?

因为我们大部分的业务应用场景是 Custom Server,所以会关注到这个配置项,先看一下文档

默认情况下,next 会自动在服务端给 pages 目录下的文件生成对应的访问地址,但是:

disables filename routes from SSR; client-side routing may still access those paths.

module.exports = {
  useFileSystemPublicRoutes: false
}

客户端如何做路由拦截

使用 next/routerbeforePopState

router.beforePopState(cb)

参数 cb 返回 false,就不会执行 popstate

具体的参数如下:

router.beforePopState(({ url, as, options }) => {
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant