nwidart/laravel-modules 使用blade组件,无法使用组件变量
laravel-modules 8.2版本
使用php artisan module:make-component Alert Test,成功创建alert组件(make-component命令在8.2版本中无法使用,作者已经指出了bug。解决方法)
modules配置文件使用的默认配置文件,没有做任何更改。
在blade模板中使用该组件(Modules/Test/ResourceViews/Components/alert.balde.php),无法使用Alert类中的$id变量,测试Alert类没有执行。
<x-test::alert :id='$id'></x-test::alert>
Alert组件类(Modules/Test/View/Component/Alert.php)
namespace Modules\Test\View\Component;
use Illuminate\View\Component;
class Alert extends Component
{
public $id;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct()
{
//
$this->id = 'test-1'
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\View\View|string
*/
public function render()
{
return view('test::components.alert');
}
}
请高手指点,感谢!!
推荐文章: