Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
更改此行
<body id="<?php echo $_COOKIE["theme"]; ?>">
对此
<body id="<?php echo $theme; ?>">
还有这个
if ($_COOKIE["theme"]=="light")
if ($theme=="light")
您的问题是,当您在当前页面加载中设置 cookie 时,它在下一个页面加载之前不可用。因此,为什么刷新似乎使它起作用。