0
我目前有一个<Login/>
页面和一个<Dashboard/>
。删除componentIdMount上的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