修改router/index.js,添加redirect路由
{
path: '/redirect',
component: Layout,
hidden: true,
children: [
{
path: '/redirect/:path*',
component: () => import('@/views/redirect/index')
}
]
},修改/src/layout/components/Sidebar/SidebarItem.vue文件,在el-menu-item标签上添加click监听
@click="clickLink(item.path)"
点击侧边栏时先跳转到/views/redirect/index.vue上,再跳回原页面
clickLink(path) {
this.$store.dispatch('query/clearQuery')
const { fullPath } = this.$route
this.$router.replace({
path: '/redirect' + fullPath
})
},在/views/redirect/index添加以下代码(感觉没啥用不添加也行)
<script>
export default {
created() {
const { params, query } = this.$route
const { path } = params
this.$router.replace({ path: '/' + path, query })
},
render: function(h) {
return h() // avoid warning message
}
}
</script>点击侧栏即可跳到redirect/index.vue再跳回原页面,实现刷新效果!