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

请高手指点,感谢!!

《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
讨论数量: 1

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