[jsx] 태그 내 조건으로 style 적용

DONNIE·2023년 1월 5일
0

자바스크립트

목록 보기
4/7

구현내용

  • 댓글/대댓글 기능
  • depth 값으로 대댓글일 경우 들여쓰기
<ul>
     {lists.map((list,index)=>{
       return (
         <li key={`list`+index} style={
           list.depth===2)
           ?
           {marginLeft:'2vw'} // 중괄호!!!!!!!!!!!!!!!!!!!!!!!!!!!!
           :
           null
         }>
          <p className="writer" style={
            (list.depth===2)
              ?
              {width:'10vw'}
              :
              ull
          }>{list.replier}</p>
          <p className="content">{list.content}</p>
          <p className="time">{moment(list.date).format('YYYY-MM-DD HH:mm')}</p>
         </li>
      )
      })}
</ul>
profile
후론트엔드 개발자

0개의 댓글