发布于 4年前

Laravel 中使用 Vue 如何处理路由冲突

在 Laravel 项目中基于 Vue 构建 SPA 应用,如何解决路由冲突问题(比如后台 Admin 系统完全使用 Vue 搭建):

1) Configure the Vue router

// using HTML5 history mode
var router = new VueRouter({
    history: true,
    saveScrollPosition: true,
    root: '/admin'
})

2) 在 Laravel 路由文件中新增:

get('admin/{subs?}', ['middleware' => 'auth', function () {
    return view('admin');
}])->where(['subs' => '.*']);

Ref:https://gist.github.com/jwalton512/9f1af52981dcbd236274

©2020 edoou.com   京ICP备16001874号-3