dppppp

5594 经验值

还是不行 /(ㄒoㄒ)/~~ 老师 你做这个视频的时候 用的la是什么版本啊 还有这个包是什么版本的啊?

'supportsCredentials' => false,
    'allowedOrigins' => ['*'],
    'allowedHeaders' => ['*'],
    'allowedMethods' => ['*'],
    'exposedHeaders' => [],
    'maxAge' => 0,
    'hosts' => [],

老师 你看这个有什么需要改的嘛?

Route::group(['middleware' => 'cors'], function(\Illuminate\Routing\Router $router){
    $router->get('/api/tasks', function () {
        return \App\Task::all();
    });

    $router->get('/api/task/{id}', function ($id) {
        return \App\Task::find($id);
    });

    $router->post('/api/task/create',function(\Illuminate\Http\Request $request){
        return 111;
    });
});

改成这样了 还是get 好使 post 不好使

Route::group(['middleware'=>'api'],function(){
    Route::get('/api/tasks', function () {
        return \App\Task::all();
    });

    Route::get('/api/task/{id}', function ($id) {
        return \App\Task::find($id);
    });

    Route::post('/api/task/create', function () {
        return \App\Task::all();
    });
});
protected $routeMiddleware = [
        'auth' => \App\Http\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'api' => \Barryvdh\Cors\HandleCors::class,
    ];
Route::group(['middleware'=>'api'],function(){
    Route::get('/api/tasks', function () {
        return \App\Task::all();
    });

    Route::get('/api/task/{id}', function ($id) {
        return \App\Task::find($id);
    });

    Route::post('/api/task/create', function () {
        
    });
});

我用的是5.1这么写的

老师 我看那个github上laravel-cors这个文档有变,我按照他的方法设置以后,在测试的时候,get的方式请求是ok的post还是会出现错误

XMLHttpRequest cannot load http://la51.me/api/tasks. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 500.
createError.js?8e8c:16 Uncaught (in promise) Error: Network Error
    at createError (createError.js?8e8c:16)
    at XMLHttpRequest.handleError (xhr.js?21f6:87)

image.png

image.png

老师 可是我下载好了 没有您的那个效果呢

老师 这个vue的插件叫什么啊 如何安装呢

<!--- $VALUE$ Field --->
<div class="form-group">
    {!! Form::label('$NAME$', '$VALUE$:') !!}
    {!! Form::text('$NAME$', null, ['class' => 'form-control']) !!}
</div>

老师请问一下,这个label的第二个参数是干吗的啊?

好的,老师,是准备订阅来着,也是决定从第一个视频开始往后看,感觉还是要有的东西很难理解很难记,老师说的这个思路正是我想问的,就是看你视频的先后顺序,能更细点跟我说明一下吗?