这次给大家带来使用Vue动态设置路由参数,的注意事项有哪些,下面就是实战案例,一起来看一下。
1.使用this.$router.go(),与js histroy.go() 用法一直,前进1,后退-1,当前页面:0
注意 使用go时 必须是已经有访问历史记录了
案例:
<template>
<p>
<button @click="goht">后退<button> <br/>
<button @click="goqj">前进<button> <br/>
<button @click="gosx">刷新当前<button>
</p>
</template>
<script>
export default {
methods: {
goht(){
this.$router.go(-1);
},
goqj(){
this.$router.go(1);
},
gosx(){
this.$router.go(0); //或者 this.$router.go();
}
}
}
</script>2.使用push调用:
案例
<template>
<p>
<button @click="pageA">去A页面</button> <br/>
<button @click="pageB">去B页面</button> <br/>
</p>
</template>
<script>
exprot default {
methods: {
pageA(){
//去路由A页面,字符串形式只能是path,类似to="path"
this.$router.push('/RouterA');
},
pageB(){
//去路由B页面,数组形式,类似 :to="{}"
this.$router.push(
{
name: 'RouterB',
query: {'name': 'name1', title: 'title1'}
//,params:{'name': 'name2', title: 'title2'}
}
);
}
}
}
</script>相信看了本文案例你已经掌握了方法,更多精彩请关注php中文网其它相关文章!
推荐阅读:
[PHP房产程序|BBWPS]功能介绍 1、5种信息类别发布:出租、求租、出售、求购、楼盘信息,支持会员发布信息审核; 2、灵活的信息参数设置; 3、充足的信息字段; 4、简单易用的发布/编辑功能,支持配图上传; 5、灵活的信息管理功能; 6、信息输出伪静态,方便搜索引擎抓取数据; 7、支持RSS输出; 8、内置数据高速缓冲技术,可灵活设置缓冲功能是否启动及过期时间; 9、支持 Google 地图
0
以上就是使用Vue动态设置路由参数的详细内容,更多请关注php中文网其它相关文章!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号