uniapp打包hash和history两种模式的区别

在uniapp打包成H5时,会有一个路由模式供你选择,有两种分别是:hash和history

在这里插入图片描述
这两者的主要区别如下:

1:hash - 地址栏会带#

比如在HbuilderX里启动一个uniapp项目,在地址后面会加一个#然后再加上页面地址,如:

http://localhost/#/pages/index/index

它的特点在于:hash虽然出现在URL中,但不会被包括在HTTP请求中,对后端完全没有影响,因此改变hash不会重新加载页面。

2:history - 正常的网址

比如这种:http://localhost/pages/index/index

所以可以根据自己的实际情况去选择。

猜你喜欢

转载自blog.csdn.net/mashangzhifu/article/details/118416768