@RLYamakasi

Почему консоль говорит, что это не функция?

this._handleCardClick is not a function - ошибка консоли

это код:

export default class Сard {
  constructor(place,source,handleCardClick){ 
    this._place = place; 
    this._source = source; 
    this._blockTemplate = document.querySelector('#blockTemplate').content; 
    this._popupTypeImage = new PopupWithImage(popUpImage,this._place,this._source); 
    this._handleCardClick = handleCardClick;
  } 

  _getTemplate(){  
    return this._blockTemplate.querySelector('.element').cloneNode(true); 
  } 

  _setEventListeners(){ 
    this._img.addEventListener('click', () => {
      this._handleCardClick(this._name, this._link)
    }); 
    this._element.querySelector('.element__bin').addEventListener('click', this._deleteBlock); 
    this._element.querySelector('.element__button').addEventListener('click', this._setLike); 
  } 

  _deleteBlock = (event) => {  
    event.target.closest(".element").remove();  
  } 

  _setLike = (event) => {  
    event.target.classList.toggle('element__button_active'); 
  } 

  makeBlock(){ 
    this._element = this._getTemplate(); 
    this._img = this._element.querySelector('.element__image'); 
    this._title = this._element.querySelector(".element__text"); 
    this._img.src = this._source; 
    this._img.alt = this._place; 
    this._title.textContent = this._place;  
    this._setEventListeners(); 
    return this._element 
  } 
  }


function createCard(name,source) {
const card = new Card(name,source,handleCardClick);
const cardElement = card.makeBlock();
return cardElement
}

export function handleCardClick(name, link) {
   popupWithImage.open(name, link)
  console.log(name,link)
}
  • Вопрос задан
  • 294 просмотра
Пригласить эксперта
Ответы на вопрос 1
@qwazimord
Интроверт
У вас в этой строке
export default class Сard {
вместо английской буквы C стоит русская буква С
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы