企业官网建站 小程序开发 云逸学习园地
技术文章 许愿墙
技术文章 PHP学习 Javascript学习 DIV+CSS学习 uniapp学习 HTML学习 微信小程序、公众号知识点 VUE知识学习
您所在的位置>云逸小栈>VUE知识学习>正文

vue跳转的几种方式,以及参数的传递方式

2024-05-04 22:12:00 浏览 1746

一、this.$router.push

说明:跳转到指定URL,向history栈添加一个新的记录,点击后退会返回至上一个页面

使用:

this.$router.push('/index')
this.$router.push({path:'/index'})
this.$router.push({path:'/index',query:{name: '123'}})
this.$router.push({name:'index',params:{name:'123'}})

this.$router.push({name:'路由命名',params:{参数名:参数值,参数名:参数值}})

接收值

this.$route.params.参数名

this.$route.query.参数名


二、this.$router.replace

说明:跳转到指定URL,替换history栈中最后一个记录,点击后退会返回至上上一个页面

使用:同push


************

路由的懒加载     直接在路由里写   {path:路径,name:名字, compoent:()=> import(I'./view/about.vue')}

compoent是路由的懒加载设置  秒开 


 this.$emit  是子组件触发父组件的事件


三、this.$router.go(n)

说明:类似window.history.go(n),向前或向后跳转n个页面,n可正(先后跳转)可负(向前跳转)

使用:

this.$router.go(1)    //类似history.forward()
this.$router.go(-1)   //类似history.back()


网站开发者电话

18066742510

个人微信号
个人公众号
个人小程序
个人抖音