laravel - Laravel 子路由中的 Vue Router 找不到正确的组件
问题描述
我在另一个 Laravel/Vue 项目上运行了几乎相同的配置,该项目运行良好,但在主要路线上/
。在这里,我将 Vue 实例分组到一个admin
子路由中,我在管理员路由到PageNotFound
我设置的组件之后键入的所有内容。
我在 web.php 中的路线:
Route::group(['prefix' => 'admin'], function() {
Route::get('/{route?}', 'AdminController@index')
->where('route', '.*')->fallback();
});
我的 Vue 路由器设置:
const router = new VueRouter({
mode: 'history',
// linkActiveClass: 'active',
linkExactActiveClass: 'exact-active',
routes: [
{
path: '/', // Solution: '/admin' not just '/'
component: Dashboard,
meta: {
title: 'Dashboard',
metaTags: [
{
name: 'description',
content: 'The about page of our example app.'
},
{
property: 'og:description',
content: 'The about page of our example app.'
}
]
},
},
{
path: '*',
component: PageNotFound,
meta: {
title: '404 - Page Not Found',
metaTags: [
{
name: 'description',
content: 'The about page of our example app.'
},
{
property: 'og:description',
content: 'The about page of our example app.'
}
]
},
}
],
});
解决方案:
似乎 Vue Router 并不关心我在 Laravel 中定义的任何前缀,它会查看完整路径,因此在上面的仪表板中,我指定了/
实际应该是的路径/admin
。
解决方案
admin 保留在 webserver 中,例如使用管理员作为前缀
推荐阅读
- git - 如何使用将部署到非 Azure ftp 的 TFS/GIT 创建构建管道?
- php - 是否可以使用变量名加载 XML 文件?
- php - 如何避免函数上的未定义索引错误以检测 PHP 中的未定义索引?
- artificial-intelligence - 将模型从 Caffe 转换为 ONNX
- php - 关于如何将多个预订链接到单个交易的建议
- javascript - 使用按钮自动为滑块设置动画
- reactjs - “http://localhost:3000”已被 CORS 策略阻止:请求的资源上不存在“Access-Control-Allow-Origin”标头
- r - 散点图的 Highcharter 位置闪避
- twitter-bootstrap - Bootstrap 4 导航栏没有正确排列
- python - 无法将 Python socketio 服务器连接到节点 js socketio 客户端