laravel8 jetstream 脚手架中 调用components x-jet 的使用原理

最近重新学习laravel8 jetstream 脚手架,遇到了一个很诡异的问题, component组件调用的时候全部写的是<x-jet-名称></x-jet-名称> 类似的, 不知道在哪儿设置这个x-jet,怎么能自己的项目中一样的处理方式修改新增的components, 比如 x-home 或者 x-dev 等重写使用,有人能解释一下吗?

《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
最佳答案

App\Providers\JetstreamServiceProvider的 register 中加入:

    public function register()
    {
        \Illuminate\Support\Facades\Blade::component('jetstream::components.liamhao', 'jet-liamhao');
    }

然后你就能用<jet-liamhao> </jet-liamhao>

来源于 Stack Overflow

3年前 评论
讨论数量: 4

App\Providers\JetstreamServiceProvider的 register 中加入:

    public function register()
    {
        \Illuminate\Support\Facades\Blade::component('jetstream::components.liamhao', 'jet-liamhao');
    }

然后你就能用<jet-liamhao> </jet-liamhao>

来源于 Stack Overflow

3年前 评论

components 的路径在 admin/components 的话 jetstream::component 怎么找到此路径,有没有相关设置》

3年前 评论

解决了
在 App\Providers\JetstreamServiceProvider 的 register 中加入:

  public function register()
    {
        \Illuminate\Support\Facades\Blade::component(Home::class, 'home-welcome');
        \Illuminate\Support\Facades\Blade::component(Admin::class, 'Admin-welcome');
    }

使用的方式<x-home-welcome /><x-admin-welcome/>

3年前 评论
mengdodo
$ php artisan make:component MyComponent

创建两个文件 /resources/views/components/my-component.blade.php 和 /app/View/Components/MyComponent.php.

只需要编辑my-component.blade.php文件内容,然后在你需要植入的视图地方使用 x-tag ,例如:

<x-my-component></x-my-component>
2年前 评论

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