vue访问后端返回的路径,直接下载文件,后端路径格式与  www.baidu.com 类似,

用原生 js 解决发现路径前拼接上了默认路径,实际跳转的路径为  localhost:8080/www.baidu.com 与预期不符合。

参照别人的解决办法:针对我自己的情况,要在路径前面加上 http://

data() {
  return {
    url: '',
  };
},
methods: {
getURL(){
  axios.post(params,url).then((res)=>{
this.url = 'http://' + res (前面拼接上一个http 这个很关键,后端返回的路径没有加协议,否则无法访问,提示私密链接之类的)
})
}, jump(){ window.location.href
= this.url; }, },

参考链接:https://blog.csdn.net/tom_wong666/article/details/85938880

相关文章:

  • 2021-05-07
  • 2021-12-05
  • 2021-05-21
  • 2022-12-23
  • 2023-03-20
  • 2021-06-20
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-26
  • 2022-12-23
  • 2021-04-29
  • 2021-12-24
相关资源
相似解决方案