Uncaught SyntaxError: Unexpected token < in JSON at position 0 ... in livewire

时间:2021-07-25 07:13:28

标签: laravel-livewire

选择文件后,控制台会显示这个错误:

enter image description here

刀片文件:

  <form wire:submit.prevent="Insert" enctype="multipart/form-data">

    <input type="file" wire:model.lazy="img" id="img" name="img"/>

    @if ($img)
        <img src="{{ $img->temporaryUrl() }}">
    @endif
    <div wire:loading wire:target="img">در حال آپلود ... </div>


    <button type="submit"> Submit </button>
   </form>

class livewire $img 是模型:

class Article extends Component
{

    use WithFileUploads;

    public $img;


    public function Insert()
    {
        dd($this->img);
    }


    public function render()
    {
        return view('livewire.article');
    }
}

0 个答案:

没有答案