vue项目中跳转到外部链接方法

 

 

 

在项目文件中,如果是vue页面中的内部跳转,用this.$router.push()可以实现,

 

 例如:
this.$router.push({path: '/channeldetailview', query: {channelid: this.data.id}});

 

跳到外部链接,不能用这个。不然就会报错,看一下链接的路径,原来外部链接前面加上了http://localhost:8080/#/这一串导致跳转出现问题

那么我们如何跳转到外部链接呢,我们只需用 window.location.href = ‘url’来实现

 例如:
window.location.href = examurl
         window.location.href = 'www.baidu.com'

 

posted @ 2020-06-05 16:44  OIMMZC  阅读(10334)  评论(0编辑  收藏  举报