• 카테고리

    질문 & 답변
  • 세부 분야

    프론트엔드

  • 해결 여부

    미해결

검색결과 1

22.01.18 11:16 작성 조회수 154

0

- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요!
- 먼저 유사한 질문이 있었는지 검색해보세요.
- 서로 예의를 지키며 존중하는 문화를 만들어가요.
- 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요.
 
 
똑같이 한거 같은데
실행하면 Controller.js에서 오류가 납니다.
render함수 호출하고
render() { if (this.store.searchKeyword.length > 0) { this.searchResultView.show(this.store.searchResult); return; }
show 부분에서
Uncaught TypeError: Cannot read properties of undefined (reading 'show')
라고 나옵니다.
이유가 뭔지 모르겠네ㅐ요;;; 똑같이 따라했는데,..,,.ㅠ

답변 1

답변을 작성해보세요.

0

searchResultView에서 show를 읽으로려하는데 오류가 났네요. this.searchResultView의 값이 undefined로 나오는데요. 생성자 함수에서 값을 할당한 코드가 있는지 확인 한 번 해보세요.

this.searchResultView = searchResultView;

확인하셨다면 컨트롤러를 생성할때 뷰를 제대로 전달했는지도 확인해 보시고요. 오타가 원인일 수도 있습니다.

 

  const views = {
    searchFormView: new SearchFormView(),
    searchResultView: new SearchResultView(),
    tabView: new TabView(),
    keywordListView: new KeywordListView(),
    historyListView: new HistoryListView(),
  };

  new Controller(store, views);