connectedCallback() {
Код: Выделить всё
fetch('/article.json')
.then(response => response.json())
.then(articlesRetrieved => this.articles = articlesRetrieved);
}
set articles(value) {
value.forEach(article => {
const articleCard = new ArticleCard();
articleCard.title = article.title;
articleCard.image = article.image;
articleCard.autor = article.autor;
articleCard.company = article.company;
articleCard.description = article.description;
articleCard.id = article.autorId;
this.articlesContainer.appendChild(articleCard);
});
}
потому что в моем классе ArticleCard у меня есть установщик
Код: Выделить всё
set authorId(id) { this.authorId = id; }Код: Выделить всё
autorButton.addEventListener('click', () => {
const autor = new Author(this.authorId);
autor.name = this.autor;
autor.image = this.image;
autor.description = this.description;
this.shadowRoot.appendChild(autor);
});
const autor = new Author(this.authorId);
< /code>
Этот код работает, и делайте то, что он должен делать, но почему? Я имею в виду, что в этой строке articlecard.id = article.autorid; Подробнее здесь: https://stackoverflow.com/questions/793 ... javascript
Мобильная версия