0
나는 현재 <Login/>
페이지와 <Dashboard/>
페이지를 가지고 있습니다.componentDidMount에서 backgroundImage 제거
로그인 페이지가 #222
의 배경을 가지고 있으며, 당신이 로그인 할 때 대시 보드 whitesmoke
방법 나는이 몸 CSS에서이를 데 뭐하는 거지의 배경이 있습니다
body {
background-color: #222222;
}
과 이 Dashboard.js
:
componentWillMount() {
document.body.style.backgroundColor = "whitesmoke";
}
componentWillUnmount() {
document.body.style.backgroundColor = null;
}
지금까지는이 기능이 작동했습니다.
body {
background-color: #222222;
background: url('../../public/img/bg.png');
background-repeat: repeat;
}
하지만이 같은 둘 때 내 대시 보드도, 배경 이미지를 상속 : 어떻게
componentWillMount() {
document.body.style.backgroundImage = null;
document.body.style.backgroundColor = "whitesmoke";
}
componentWillUnmount() {
document.body.style.backgroundColor = null;
}
을 여기에 본 그러나 지금, 로그인 페이지에서 내 배경으로 이미지를 나는이 문제를 해결할 수 있을까? 감사합니다.
'null'은 backgroundImage의 유효한 값이 아니며 브라우저에서 무시됩니다. 'document.body.style.backgroundImage = 'none';을 사용하십시오. – pawel