많은 ReactJs 프로젝트에서 그중 하나가 아래 오류를 던지고 있습니다.
Error: Material-UI: unsupported non-unitless line height with grid
alignment. Use unitless line heights instead.
에서 lineHeight를 정의하는 동안 px
아래 코드는 다음과 같습니다.
const breakpoints = createBreakpoints({});
let theme = createMuiTheme({
typography: {
allVariants: {
fontFamily
},
h1: {
fontWeight: 600,
fontSize: 26,
lineHeight: '32px',
[breakpoints.down("sm")]: {
fontSize: 18,
lineHeight: '26px',
}
},
h2: {
fontWeight: 600,
fontSize: 20,
lineHeight: 28 / 20
},
h3: {
fontWeight: 600,
fontSize: 16,
lineHeight: '22px',
[breakpoints.down("sm")]: {
fontSize: 14,
lineHeight: '20px',
}
}
}
})
위의 예에서, 내가 변경하는 경우 lineHeight
의 h1
나 h2
에 px
값이 오류가 발생합니다,하지만에 대한 오류가 발생하지 않습니다 h3
오히려 내가 년은 lineHeight을 정의 px
또는 단위가없는 값입니다.
h1
in의 lineHeight를 정의했기 때문에 오류가 발생하는 위 코드는 px
아래 코드로 변경하면 작업을 시작합니다.
h1: {
fontWeight: 600,
fontSize: 26,
lineHeight: 32 / 26
},
왜 이런 일이 일어나는지 알려주세요. 검색했지만 StackOverflow에서 관련 문제를 찾지 못했습니다.
아마도 코드 어딘가 에서이 오류를 발생 시키는 코드가 포함되어 있기 때문에 responsiveFontSizes 함수를 사용하고 있을 것 입니다.
responsiveFontSizes 내h3
에서 다음 조건으로 인해 오류가 발생하지 않습니다 .
if (remFontSize <= 1) {
return;
}
귀하 h3
의 글꼴 크기는 1 rem 인 16이므로 responsiveFontSizes
해당 변형에 대해 아무것도하지 않으므로 오류가 발생하지 않습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다