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