vue3.0 去掉#解决步骤

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/besttoby01/article/details/84584151

问题描述:微信分享 会自动去掉#后面的参数,所以你分享的话都是去首页。

需求:微信分享需要去的不是首页,而是内部的详情页。

解决步骤:

1. 修改 mode为history,默认的是hash模式,这样子就会去掉了#

2.修改服务器的配置,代码如下:

location / {
      try_files $uri $uri/ /index.html;
 }
    
 location /dist {
     root /www/wwwroot/jzmcy.com;
     try_files $uri $uri/ /dist/index.html;
 }

上面一个是固定的,不知道干什么(官网的答案,解决history的)

下面一个是修复 去了别的h5页面,然后回到页面会出现504问题。

location / {
      try_files $uri $uri/ /index.html;
 }
    

这部分可以放在静态文件里面

location /dist {
     root /www/wwwroot/jzmcy.com;
     try_files $uri $uri/ /dist/index.html;
 }

这部分可以放在配置文件里面

3.修改vue的config.js文件的baseurl,采用绝对路劲

baseUrl: process.env.NODE_ENV === 'production' ? '/dist/' : '/',

猜你喜欢

转载自blog.csdn.net/besttoby01/article/details/84584151