【问题标题】:Laravel Livewire Timing OutLaravel Livewire 超时
【发布时间】:2021-05-19 14:51:43
【问题描述】:

嘿,你们这些聪明人,我需要一些 livewire 的帮助,我在我的组件中向外部 API 发出请求,我想在刀片上显示它,但是它只是一直超时,所以想知道是否有人可以提供帮助我的脚本在下面,是我在渲染视图和超时之前拥有的 ddd 的示例......

<?php

namespace App\Http\Livewire;

use Illuminate\Support\Facades\Http;
use Livewire\Component;

class Users extends Component
{
    public $users;

    public function render()
    {
        $response = Http::get('http://url/api/all');
        $response = $response->json();
        $users = $response['data'];
        dd($users);

        return view('livewire.users', compact(['users']));
    }
}

这是 DD $users 的示例

array:13 [▼
  "current_page" => 1
  "data" => array:7 [▶]
  "first_page_url" => "http://url/api/all?page=1"
  "from" => 1
  "last_page" => 1
  "last_page_url" => "http://url/api/all?page=1"
  "links" => array:3 [▶]
  "next_page_url" => null
  "path" => "http://url/api/all"
  "per_page" => 15
  "prev_page_url" => null
  "to" => 7
  "total" => 7
]

但是,如果我取出 DD 并尝试渲染视图,它就会超时,这就是我的视图刀片。

@extends('layouts.master')

@section('content')

@livewire('users')

    {{dd($users)}}

@endsection

我已尝试使用 $this->users 以及您在示例中看到的 compact,如果你们中的任何人知道我可能做错了什么,您能否指导我走向正确的方向..

我是一个 API 人,我对前端的东西不太擅长啊哈哈

感谢您的宝贵时间

【问题讨论】:

    标签: laravel components laravel-blade laravel-8 laravel-livewire


    【解决方案1】:

    根据 livewire 的创建者 Caleb 的说法,“我们最近实施了一个相当大的内部安全功能,它可能会导致问题。”

    查看他最近在 GitHub 问题上发表的评论 Session expire after 30s-1min when using livewire components directly with Illuminate\Support\Facades\Route

    他建议,要么降级到 2.3.8 版,要么降级到 2.3.18 版。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-20
      • 2020-12-12
      • 2021-01-21
      • 1970-01-01
      • 1970-01-01
      • 2023-02-22
      • 1970-01-01
      相关资源
      最近更新 更多