我有一个 Laravel 7 组件,如下所示
class Input extends Component
{
public $name;
public $title;
public $value;
public $type = 'text';
/**
* Create a new component instance.
*
* @return void
*/
public function __construct($name, $title)
{
$this->name = $name;
$this->title = $title;
$this->value = \Form::getValueAttribute($name);
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\View\View|string
*/
public function render()
{
return view('components.fields.input');
}
}
Run Code Online (Sandbox Code Playgroud)
我可以像这样在 Blade 组件中渲染该字段:
<x-input name="name" :title="__('My field')" />
我需要在代码中创建和渲染该字段,我尝试了以下操作:
$field …Run Code Online (Sandbox Code Playgroud)