【发布时间】:2020-06-26 07:11:36
【问题描述】:
我正在用 laravel、vue 和 vue 路由器构建一个电子商务项目
我想在历史模式下使用 vue 路由器,但它给我带来了麻烦。
这是我的代码
new Vue({
el: '#app',
router: new VueRouter({
mode: 'history',
routes
})
});
这是我在 web.php 中的路由,其中包含语言环境中间件
Route::group(['prefix' => '{locale}', 'where' => ['locale' => '[a-zA-Z]{2}'], 'middleware' => 'setlocale'], function () {
Route::view('/{path?}', ('layouts.app'))->where('path', '.*');
});
这是我使用 vue 路由器的路线
export const routes = [
{
path: '/',
component: require('./components/Page/HomePage').default,
},
{
path: '/product',
component: require('./components/Page/Product/ProductPage').default,
},
];
我需要我的网址
http://localhost/en
而不是(带有标签)
http://localhost/en#/
使用历史模式后,我成功删除了主题标签。但是,其他的路由器链接会在我的 url 中删除我的语言环境
http://localhost/product
我现在不知道该怎么办。 请帮忙~谢谢。
【问题讨论】:
标签: laravel vue.js vuejs2 vue-router