【发布时间】:2020-03-19 07:38:30
【问题描述】:
我正在尝试从constructor 复制this.card。但是,到目前为止它不起作用。也许这是不可能的。无论如何,有人可以告诉我该怎么做吗?
class CardList {
constructor(card) {
this.card = card;
}
render(container, cards) {
this.container = container;
this.cards = cards;
this.cards.forEach(card => {
this.card.placeImage.setAttribute(
"style",
`background-image: url(${card.link})`
);
this.card.placeName.textContent = card.name;
this.container.appendChild(this.card.placeCard);
});
}
}
【问题讨论】:
标签: javascript class closures