admin管理员组文章数量:1354396
I am trying to use the Symfony UX LiveComponent, firstly I tried to use the first exemple of the documentation:
// ArticleSearch.php
<?php
namespace App\Twig\Components;
use App\Repository\ArticleRepository;
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
use Symfony\UX\LiveComponent\Attribute\LiveProp;
use Symfony\UX\LiveComponent\DefaultActionTrait;
#[AsLiveComponent]
class ArticleSearch
{
use DefaultActionTrait;
#[LiveProp(writable: true)]
public string $search = '';
public function __construct(private ArticleRepository $articleRepository)
{
}
public function getArticles(): array
{
return $this->articleRepository->findBy(['title' => $this->search]);
}
}
<!-- ArticleSearch.html.twig -->
<div {{ attributes }}>
<input
type="search"
data-model="search"
>
<ul>
{% for article in this.getArticles %}
<li>{{ article.title }}</li>
{% endfor %}
</ul>
</div>
The attributes are showing, but the value of $search is never updating, so nothing happends.
It happends when I use the symfony local:server:start, can it cause a problem ?
Thanks
EDIT:
Here's the content of my app.js and bootstrap.js:
// app.js
import './bootstrap.js';
/*
* Welcome to your app's main JavaScript file!
*
* This file will be included onto the page via the importmap() Twig function,
* which should already be in your base.html.twig.
*/
import './styles/app.css';
console.log('This log comes from assets/app.js - welcome to AssetMapper!
本文标签:
phpLiveComponent isn39t updating the LiveProp valueStack Overflow
版权声明:本文标题:php - LiveComponent isn't updating the LiveProp value - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人,
转载请联系作者并注明出处:http://www.betaflare.com/web/1744011151a2575588.html,
本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论