NumberFormat 문제

Sbae·2024년 2월 14일
0
post-thumbnail

개발환경

  • Nuxt, PrimeVue3 사용

문제점

  • 1000이 넘는 숫자를 K, M 등으로 변환하고 소수점도 잘라서 표현하는 문제

해결방법

  • new Intl.NumberFormat() method를 사용한다.

  • new Intl.NumberFormat("en", { minimumFractionDigits: 3, maximumFractionDigits: 3, notation: 'compact' }).format(convertNumber);

    • notation ◀︎ standard, scientific, engineering, compact, 과학, 공학적 표현이나 간결한 표시
    • minimumFractionDigits ◀︎ 최소 소수점 표현
    • maximumFractionDigits ◀︎ 최대 소수점 표현
  • 미국식으로 표현 됨 K, M, T 등등


참조

profile
끄적이는 일반인

0개의 댓글