• 카테고리

    질문 & 답변
  • 세부 분야

    프론트엔드

  • 해결 여부

    미해결

Console 에러

21.02.04 18:42 작성 조회수 121

1

콘솔창에 heightNum=5 줄이

Uncaught SyntaxError: Invalid shorthand property initializer

에러 뜨는데, 동영상3번 돌려봐도 잘 모르겠어요 ㅠ

//즉시호출함수
(() => {
  //스크린 높이
  const sceneInfo = [
    {
      // 0
      // 브라우저 높이의 5배로 scrollHeight 세팅
      //디바이스마다 높이가 다르기 때문에 각 기계의 높이를 가지고 와서 x5를 함
      type: 'sticky',
      heightNum = 5,
      scrollHeight : 0,
      objs:{
        container:document.querySelector('#scroll-section-0')
      }
    },
    {
      // 1
      type: 'normal',
      heightNum = 5,
      scrollHeight : 0,
      objs:{
        container:document.querySelector('#scroll-section-1')
      }
    },
    {
      // 2
      type: 'sticky',
      heightNum = 5,
      scrollHeight : 0,
      objs:{
        container:document.querySelector('#scroll-section-2')
      }
    },
    {
      // 3
      type: 'sticky',
      heightNum = 5,
      scrollHeight : 0,
      objs:{
        container:document.querySelector('#scroll-section-3')
      }
    }
  ];

  function setLayout(){
    //각 스크롤 섹션의 높이 세팅
    for (let i = 0; i < sceneInfo.length; i++){
      sceneInfo[i].scrollHeight = sceneInfo[i].heightNum * window.innerHeight;
      sceneInfo[i].objs.container.style.height = `${scrollHeight[i].scrollHeight}`;
    }

    console.log(sceneInfo);
  }

  setLayout();
})();

답변 2

·

답변을 작성해보세요.

1

mill님의 프로필

mill

2021.02.05

모든 heightNum = 5가 = 로 잘못 들어가 있네요. =을 :로 변경하세요.
heightNum : 5

0

장근호님의 프로필

장근호

질문자

2021.02.05

ㅎㅎㅎ감사합니다ㅎㅎㅎ