: https://potensj.tistory.com/122
// num : 변환할 숫자
// n : 소숫점 자릿수
function toFixedNumber(num, n) {
return Number(num.toFixed(n));
}
: 모바일에서 특정 위치로 scrollTo하고, 그 엘리먼트가 가진 paddingTop, 그리고 fixed된 헤더의 높이값 만큼 top 값을 빼줬는데 브라우저 크기 마다 오차가 발생했다.
자바스크립트를 통해서 계산한 값 또한 toFixed를 이용해서 소숫점 3번째 자리까지 반올림해서 계산했더니 딱 맞게 떨어졌다.
const newArray = array.slice(0, n);
async fetchData(onSuccess, onError) {
try {
this.loading = true;
const params = {
id: "",
};
const result = await api.getUser(params);
this.loading = false;
if( typeof onSuccess === "function" ) {
onSuccess(result);
}
} catch (error) {
// error
if( typeof onError === "function" ) {
onError(result);
}
}
}