在使用laravel混合开发的时候
就是不是前后端分离,将模板文件写在resource中
在表单验证的时候出现以下问题
`Undefined variable: errors (View: C:\wamp\www\StuLaravel5\resources\views\login.blade.php)`
解决办法:
```
在使用$error时需要用到中间件:
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
```
以下为中间件
```
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
],
'api' => [
'throttle:60,1',
],
];
```