📜  从 laravel 发送对象以响应 js 组件 - 任何代码示例

📅  最后修改于: 2022-03-11 14:57:09.549000             🧑  作者: Mango

代码示例1
// Inside AppServiceProvider::boot
Blade::include('includes.react', 'react');

// Create a includes/react.blade.php file
//Inside your views just include ($props must be an array) @react(['id' => 'user-dropdown', 'props' => $props]) //Using this approach you can pass more complex data: @react([ 'id' => 'user-dropdown', 'props' => [ 'name' => Auth::user()->name, 'obj' => [ 'bla' => ['id' => 1] ], 'arr' => [1,2,3] ] ])