2022.8.27

问题1:项目部署到nginx服务器,浏览器访问页面刷新时404
原因:项目的vue-router设置了history模式,因为history模式下的url没有#号,在访问二级路径的时候,做刷新操作,会出现404错误。nginx服务器没有配置url重定向。

解决:nginx服务器配置url重定向,重定向首页路由,在nignx.conf中的"location /"下加上“try_files $uri $uri/ /index.html;”

点击查看代码
location / {
            root   dist;
            index  index.html index.htm;
            try_files $uri $uri/ /index.html;
        }

问题2:场景PlaylistDetail.vue中当前播放的歌曲信息songInfo明明在最近播放列表renList里面,用indexOf返回-1,两个东西不相等为false,不知道是为啥, 暂时想到的办法判断id是否相同,返回索引.....

最近播放列表中:

存放在vuex中的songInfo:

我在控制台中打印

console.log(this.renList.indexOf(row))

返回了

暂时的解决办法:

 // 更新当前播放歌曲在最近播放中的索引
      for (let i = 0; i < this.renList.length; i++) {
        if (row.id === this.renList[i].id) {
          this.songIndex = i
        }
      }
posted @ 2022-09-03 12:42  UShen  阅读(35)  评论(0)    收藏  举报