다음과 같은 경우가 있습니다
return (
<section {...getRootProps({className: 'MuiFileDropArea-dashed'})}>
My content
</section>
나는에 조건문을 넣을 단면 선 때 files.length > 0
(가) className
됩니다MuiFileDropArea-Nodashed
내가 어떻게 해?
이를 수행하기 위해 필요한 것은 백틱이있는 삼항 연산자입니다. 다른 방법이 있지만 이것은 나중에 코드를 볼 때 대부분의 사람들이 가장 쉽고 / 간단하게 읽을 수있는 방법입니다.
return (
<section {...getRootProps({className: `MuiFileDropArea-${files.length > 0 ? 'Nodashed' : 'dashed'}`})}>
My content
</section>
대안은 다음과 같습니다.
return (
<section {...getRootProps({className: files.length > 0 ? 'MuiFileDropArea-Nodashed' : 'MuiFileDropArea-dashed'})}>
My content
</section>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다