6. Vue 编程式导航与历史记录
2020-07-13 05:55
162 查看
Vue 编程式导航与历史记录
<div id="app"> <button @click="pageFirst">Page First</button> <button @click="pageSecond">Page Second</button> </br> <button @click="goBack">Go Back</button> <button @click="goForward">Go Forward</button> <router-view></router-view> </div> <script src="https://unpkg.com/vue/dist/vue.js"></script> <script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
const First = { template: '<div>First Page</div>' } //调用路由name属性 const Second = { template: '<div>Second Page</div>' } routes = [ { path:'/first', name:"first" ,component: First }, //设置路由name属性 { path: '/second', name:"second", component: Second } ] router = new VueRouter({ routes }) const app = new Vue({ router, methods: { pageFirst(){ router.push('/first') }, pageSecond(){ router.push({ name: 'second' }) }, goForward(){ router.go(1) }, goBack(){ router.go(-1) } }, }).$mount('#app')
相关文章推荐
- vue-router next(false) 禁止访问某个页面时,不保留历史访问记录
- Vue记录 this.$emit 子组件向父组件传递事件(导航的切换)
- 关于 Vue2.0-Spa 单页应用如何实现历史位置记录问题
- Vue移动端搜索页面的历史记录写法
- Vue之编程式导航
- 网站个人中心,vue实现jwt验证,历史浏览记录,退出登录,邮件绑定
- Vue 实现输入框新增搜索历史记录功能
- vue 编程式导航 router.push() 方法使用
- vue-router中参数传递 && 编程式导航 && 坑 && beforeRouteEnter
- vue-router中参数传递 + 编程式导航 + beforeRouteEnter
- Vue 编程式导航,路由history模式
- vue+elementUI实现搜索框历史记录
- vue 编程式导航
- vue路由学习-编程式路由导航
- vue 编程式导航,使用js跳转路由
- [Vue 牛刀小试]:第十四章 - 编程式导航与实现组件与 Vue Router 之间的解耦
- Vue-Router(三) 编程式导航
- vue-router中参数传递 && 编程式导航 && 坑 && beforeRouteEnter
- vue中路由传值及编程式导航
- Vue 实时监听滚动轴实现导航自动吸顶 记录一下