vue点击按钮跳转到另一个vue页面实现方法
作者:ChangYan.
这篇文章主要给大家介绍了关于vue点击按钮跳转到另一个vue页面的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考借鉴价值,需要的朋友可以参考下
首先需要对按钮绑定一个函数,然后在函数里进行页面路由的改变。这里要确保项目中已经在使用vue-router。如图,我想要跳转到这个index.vue页面

那么按钮绑定的函数里的路径应该这么写:

然后需要在router文件夹下的index.js里进行该页面的注册:

最主要的是我红框里的内容

代码如下
{
path: '/directory',
component: Layout,
name: 'Directory',
meta: {
title: 'Directory',
icon: 'el-icon-s-cooperation'
},
redirect: '/directory/index',
children: [
{
path: '',
name: 'Directory',
component: () => import('@/views/directory/index'),
meta: { title: 'navRoute.directory', icon: 'el-icon-s-cooperation', roles: ['user'] }
},
{
path: 'newfilter/index',
name: 'Newfilter',
hidden: true,
component: () => import('@/views/directory/newfilter/index'),
meta: { title: 'navRoute.newfilter', roles: ['user'] }
},
{ path: '*', redirect: 'directory/index', hidden: true }
]
},然后就可以跳转成功啦!
总结
到此这篇关于vue点击按钮跳转到另一个vue页面实现的文章就介绍到这了,更多相关vue点击按钮跳转vue页面内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
