vue 路由跳转router-link
vue里使用 <a href="list">列表</a> 会使页面刷新
使用router-link则不刷新
<ul>
<li><router-link tag="div" to="/"></router-link></li> //tag自定义跳转标签
<li><router-link to="/list"></router-link></li>
<li><router-link :to="homeLink"></router-link></li> //动态绑定路由
<li><router-link :to="{name:'homeLink'}"></router-link></li> //name绑定
</ul>
<script>
export default{
data(){
return {
homeLink:"/"
}
},
methods:{
gotoMenu(){
this.$router.go(-1) //跳转到上一次浏览页面
this.$router.replace('/menu') //跳转到指定的地址
this.$router.replace({name:'menuLink'}) //跳转到指定的路由名称下
this.$router.push('/menu') //跳转通过push 压栈到指定地址
this.$router.push({name:'menuLink'}) //跳转通过push 压栈指定name地址
}
}
}
</script>