查漏补缺——路由显示的是http://localhost:8080/#/,后面带有井号,应该怎
问题如题所示
答案
vue地址去掉 #
VUE路由去掉“#”
修改前源码是这样的:
export default new Router({
routes: [
{
path: '/',
name: 'hzhHome',
component: () => import('@/views/hzhHome.vue'),
meta: { title: '首页' }
},
{
path: '/hzhSearch/:words',
name: 'hzhSearch',
component: () => import('@/views/hzhHome.vue'),
meta: { title: '搜索', params: 'words'}
},
{
path: '/hzhAbout',
name: 'hzhAbout',
component: () => import('@/views/hzhAbout.vue'),
meta: { title: '关于' }
},
{
path: '/hzhFriend',
name: 'hzhFriend',
component: () => import('@/views/hzhFriend.vue'),
meta: { title: '友链' }
},
{
path: '/hzhArticle',
name: 'hzhArticle',
component: () => import('@/views/hzhArticles.vue'),
meta: { title: '文章' }
}
]
})修改之后源码是这样的:
export default new Router({
mode: 'history',
routes: [
{
path: '/',
name: 'hzhHome',
component: () => import('@/views/hzhHome.vue'),
meta: { title: '首页' }
},
{
path: '/hzhSearch/:words',
name: 'hzhSearch',
component: () => import('@/views/hzhHome.vue'),
meta: { title: '搜索', params: 'words'}
},
{
path: '/hzhAbout',
name: 'hzhAbout',
component: () => import('@/views/hzhAbout.vue'),
meta: { title: '关于' }
},
{
path: '/hzhFriend',
name: 'hzhFriend',
component: () => import('@/views/hzhFriend.vue'),
meta: { title: '友链' }
},
{
path: '/hzhArticle',
name: 'hzhArticle',
component: () => import('@/views/hzhArticles.vue'),
meta: { title: '文章' }
}
]
})最后的效果是这样的:
https://img2022.cnblogs.com/blog/2515183/202206/2515183-20220624121257986-1933020624.gif
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
页:
[1]