在 Tailwind CSS 中使用基于类的深色模式和 Next.js v12 时,如何防止页面闪烁,而不使用任何 3rd 方 pkg(例如 next-themes)?
我看过:
Do not add <script> tags using next/head (see inline <script>). Use next/script instead. See more info here: https://nextjs.org/docs/messages/no-script-tags-in-head-component<Script strategy="beforeInteractive" src="/scripts/darkMode.js"/>仍然会导致页面闪烁,因为它添加defer到了head// On page load or when changing themes, best to add inline in `head` to avoid FOUC
if (localStorage.theme === …Run Code Online (Sandbox Code Playgroud)