您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息
免费发信息
三六零分类信息网 > 克拉玛依分类信息网,免费分类信息发布

使用Vue动态设置路由参数

2024/5/5 15:14:34发布3次查看
这次给大家带来使用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>
相信看了本文案例你已经掌握了方法,更多精彩请关注其它相关文章!
推荐阅读:
微信小程序怎样做出弹出框功能
详细剖析vue使用
以上就是使用vue动态设置路由参数的详细内容。
克拉玛依分类信息网,免费分类信息发布

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录