Umi: 约定式路由怎么触发404?

Created on 12 Mar 2018  ·  6Comments  ·  Source: umijs/umi

dev 下我输入错误地址没有触发自定义的404页面,而是显示: umi development 404 page....

直接访问 http://localhost:8000/404 正常显示了自定义的404页面

type(question)

Most helpful comment

@sorrycc嗨云谦大大,我部署到测试环境任然不会触发自定义的404页面

All 6 comments

开发模式下,umi 会添加一个默认的 404 页面,但你仍然可通过精确地访问 /404 来验证 404 页面。

生成模式下会触发的。

好吧

@sorrycc嗨云谦大大,我部署到测试环境任然不会触发自定义的404页面

dev 下我输入错误地址没有触发自定义的404页面,而是显示空白页

直接访问 http://localhost:8000/404 正常显示了自定义的404页面

umi build 后的文件,放到本地nginx 公共目录,后同样是访问未定义的路由显示空白页,配置history: {type: 'hash'}后也是同样的表现

$ node -v
v12.12.0
$ umi -v
[email protected]

这个解决方案在issues下并没有找到啊~

@sorrycc +1,[email protected],node 10.15.3, 约定式路由下输入错误地址显示空白页面,不会自动跳转404页面

https://github.com/umijs/umi/issues/5652 尝试使用这里的老外解决方式
... NoFoundPage.path = undefined; NoFoundPage.exact = undefined; ...
对应umi生成的路由
image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ironyfive picture ironyfive  ·  3Comments

miaojinxing picture miaojinxing  ·  3Comments

tauruswang picture tauruswang  ·  3Comments

Artoria-0x04 picture Artoria-0x04  ·  3Comments

y2891663091 picture y2891663091  ·  4Comments