gpt4 book ai didi

Laravel 7 无法解析的依赖解析 - Blade 组件

转载 作者:行者123 更新时间:2023-12-04 09:30:12 24 4
gpt4 key购买 nike

我正在使用新的 Laravel 7 Blade 组件。我有一个新组件,它打开一个 Bootstrap 删除模式,如下所示:

<x-delete-modal 
:description="$task->TaskDescription"
:id="$task->TaskID"
:route="$routeForDeleteModelModal"
:modelInstance="$task"
/>
但我收到以下错误:

Unresolvable dependency resolving [Parameter #0 [ $description ]] in class App\View\Components\DeleteModal


该组件如下所示:
 <!-- Delete Model Modal -->
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true">
hello
</div>
为了确保它不是模态的内容,除了“hello”之外,我已将其全部删除。
DeleteModal 类有 4 个变量:
public $description;
public $id;
public $route;
public $modelInstance;
它的构造如下:
public function __construct($description, int $id, $route, $modelInstance)
{
$this->description = $description;
$this->id = $id;
$this->route = $route;
$this->modelInstance = $modelInstance;
}
我不确定是什么导致了这个错误 - 我已经尝试确保我所有的拼写都是正确的,将其简化为描述,并且还做了一个 dd在构造函数中,但它甚至在到达那么远之前就失败了。

最佳答案

信不信由你,但问题不在于模式,而在于其上方的 HTML 注释。
我的评论是:

<!-- 
...... lots of text

Please make sure to only include '<x-delete-modal ... />' after closing a form, as this component
contains a form, and HTML does not support nested form elements.
-->
有趣的是,包括 '<x-delete-modal ... />'在评论中导致它完全倒下。这意味着评论正在以某种方式被编译。如果有人能解释为什么会发生这种情况,我真的很想知道。
'<x-delete-modal ... />' 时,组件按预期工作从中删除。

关于Laravel 7 无法解析的依赖解析 - Blade 组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62878619/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com