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');
    }
}

请高手指点,感谢!!

《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。