Vue学习笔记十三:路由的跳转
Vue学习笔记十三:路由的跳转 Vue版本:2.5.21 Vue-router版本:3.1.6 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>路由的跳转</title> </head> <body> <!-- 路由的跳转 路由的跳转方式有: *通过标签:<router-link to='/login'></router-link> *通过js控制跳转 this.$router.push({path:'/login'}) 区别: this.$router.push()跳转到指定url。会向history插入新的记录 this.$router.replace()同样是跳转到指定的url,但是这个方法不会向 history里面添加新的记录,点击返回,会跳转到上上一个页面。上一个记录时不存在的。 this.$router.go(-1)常用来作返回,读history里面记录后退一个 vue-router中的对象: $route路由信息对象,只读对象 $router路由操作对象,只写对象 --> <div id="app"></div> <script src=