在uniapp打包成H5时,会有一个路由模式供你选择,有两种分别是:hash和history
这两者的主要区别如下:
1:hash - 地址栏会带#
比如在HbuilderX里启动一个uniapp项目,在地址后面会加一个#然后再加上页面地址,如:
http://localhost/#/pages/index/index
它的特点在于:hash虽然出现在URL中,但不会被包括在HTTP请求中,对后端完全没有影响,因此改变hash不会重新加载页面。
2:history - 正常的网址
比如这种:http://localhost/pages/index/index
所以可以根据自己的实际情况去选择。