Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
443 views
in Technique[技术] by (71.8m points)

hash路由二级目录会不会404

假设 hash 路由为 www.test.com/#/abc
即使浏览器刷新也只会发送 www.test.com来获取根目录的index.html文件所以不会404
那如果这时路由变为www.test.com/a/#/abc
浏览器发送的是www.test.com/a,而服务端没有相应的目录,也没有做其他处理,这时候会返回404吗?
如果会,那是不是和 history 路由一样要所有请求重定向到index.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

那肯定会404了, 是得和history一样去做处理输出index.html.
且在new Router中配置base选项.不然打包出来的文件引用资源会少一层子目录, 比如你这里是在子目录/a中, 那么base就配置为/a. (这些都可以通过环境变量来控制是否二级目录)

犀利一笑^_^


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...