Coder Social home page Coder Social logo

Comments (2)

github-actions avatar github-actions commented on June 14, 2024

由于缺乏足够的信息,我们暂时关闭了该 Issue。请修改(不要回复) Issue 提供最小重现以重新开启。谢谢。

from umi.

fz6m avatar fz6m commented on June 14, 2024

我修复了下,但调试发现 history 使用相对路径跳转时,当前路径最后有没有 / 是会影响跳转结果的。

比如 url path 是 /a/b 时,react router 原生提供的 useNavigate 跳转 navigate('./c') 得到的是 /a/b/c
当 url path 是 /a/b/ 时,navigate('./c') 得到的也是 /a/b/c ,尾 slash 不影响结果。

但,比如 url path 是 /a/b 时, history.push('./c') 得到的是 /a/c
url path 是 /a/b/ 时, history.push('./c') 得到的是 /a/b/c

以上这两种表现不一致,在没有设定系统的统一尾 slash 标准化的情况下, 这种不一致的行为是有问题的,使用 history 时,它只是一个比较底层的 web history (对原生 history 封装了一下)而已,不应该使用相对路径跳转,而 react router 是一个高级的路由库,它内部兼容了这些相对路径跳转,所以结果是一致的。

我们没法接受不确定的结果,如果要跳相对路径,就统一用 react router 的 useNavigate 方法吧。

from umi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.