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。
讨论数量: 1

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!