[Vue.js] TypeError:connot read properties of undefined(reading 'length')

아현·2024년 7월 26일
0

Vue

목록 보기
3/4

출처


해결방법


1) 삼항연산자 조건부 렌더링

<div>
{numberOfJoiner !== 1 ? (
  <div className="mt-[30px] h-[98px] ml-[20px]">
    참여자
    <div className="bg-[#CEE4F8] h-[50px] w-[335px] mt-[20px] p-[15px] shadow flex rounded-lg">
      {joiner &&
        joiner.map((a) => {
          return <span className="text-sm">{a.username}</span>;
        })}
    </div>
  </div>
) : (
  false
)}
</div>



2) AND 연산자 (&&)


const numberOfJoiner = joiner && joiner.length;



profile
For the sake of someone who studies computer science

0개의 댓글