我想创建一个只提供数据而没有视图的组件。
例如:
<x:wg.items.listing :items="$items->items()" :filter="$obj->settings['filter']">
@foreach($items as $item)
{{ $item->title }}
@endforeach
</x:wg.items.listing>
Blade 组件获取一个集合:items和一个:filter. 标签之间应该有一个可用的过滤集合。
清单.php:
class Listing extends Component
{
public $items;
public $filter;
/**
* Create a new component instance.
*
* @return void
*/
public function __construct($filter="0", $items="0")
{
$this->filter = $filter;
$this->items = $items;
}
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\View\View|string
*/
public function render()
{
$this->items = app()->make("App\\Http\\Controllers\\Frontend\\BlogController")->generateList($this->items, $this->filter);
/*return view('components.wg.items.list');*/
}
}
不Listing.php应该呈现视图,因为项目集合仅在上面的 Blade x 标签中可用components.wg.items.list,而不在它们之间可用。
这可能吗?先感谢您!
达令说