我在我的 getElementById('password') 上收到“无法读取 null 的属性 'style'”,但它在页面上明确定义。我是新来的,我猜这是不允许的。但我试图让密码页面显示,直到它的样式更改为“无”,这发生在不同的组件中。
function App() {
const [loggedIn, setLoggedIn] = useState(false)
if (document.getElementById('password').style.display = "block"){
setLoggedIn(false)
} else {
setLoggedIn(true)
}
return (
<div className="app">
{ //Check if message failed
(loggedIn)
? <div> <Password /> </div>
: <div>
<Nav />
<div id="allFiles">
<FileEarth title="Earth Update"/>
<FileMars title="Mars Rover Update"/>
<HardDrvie title="ASTRO Entertainment"/>
<Folder title="Moon Pics"/>
</div>
</div>
}
</div>
);
}
export default App;