2025年02月20日 建站教程
vue项目中实现链接跳转有哪些方法,如何在新页面打开,下面web建站小编带大家了解一下实现代码!
// 直接写上跳转的地址 <router-link to="/index1">link跳转</router-link> // 添加参数 <router-link :to="{path:'/index2', query:{id:1,name:'web'}}"></router-link> // 新窗口打开 <router-link :to="{path:'/index3', query:{id:1,name:'web'}}" target="_blank"></router-link>
利用this.$router.replace跳转
toIndex (e) { this.$router.replace({name: '/index', params: {id: e}}) }
利用this.$router.push跳转
toIndex (e) { this.$router.push({name: "/index", params: {id: e}}) }
利用resolve跳转
toIndex (e) { const new = this.$router.resolve({name: '/index', params: {id: e}}) window.open(new.href,'_blank') }
本文链接:http://so.lmcjl.com/news/23518/