Vue 动态设置路由参数的案例分析
时间:2018/5/9 21:49:14阅读:
在vue中 可以动态设置路由参数:1.使用this.$router.go(),与js histroy.go() 用法一直,前进1,后退-1,当前页面:0注意 使用go时 必须是已经有访问历史记录了案例:<template><div> <button @click="goht">后退<button> <br/>&l…
在vue中 可以动态设置路由参数:
1.使用this.$router.go(),与js histroy.go() 用法一直,前进1,后退-1,当前页面:0
注意 使用go时 必须是已经有访问历史记录了
案例:
<template>
<div>
<button @click="goht">后退<button> <br/>
<button @click="goqj">前进<button> <br/>
<button @click="gosx">刷新当前<button>
</div>
</template>
<script>
export default {
methods: {
goht(){
this.$router.go(-1);
},
goqj(){
this.$router.go(1);
},
gosx(){
this.$router.go(0); //或者 this.$router.go();
}
}
}
</script>