{"id":256087,"date":"2022-11-09T08:45:20","date_gmt":"2022-11-09T00:45:20","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=256087"},"modified":"2022-10-28T12:45:57","modified_gmt":"2022-10-28T04:45:57","slug":"react-linu-six","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/react-linu-six.html","title":{"rendered":"React\u53ef\u5b9a\u5236\u9ed1\u6697\u6a21\u5f0f\u5207\u6362\u5f00\u5173\u7ec4\u4ef6\u793a\u4f8b"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4e3a\u5927\u5bb6\u4ecb\u7ecd\u4e86React\u53ef\u5b9a\u5236\u9ed1\u6697\u6a21\u5f0f\u5207\u6362\u5f00\u5173\u7ec4\u4ef6\u793a\u4f8b\u8be6\u89e3\uff0c\u6709\u9700\u8981\u7684\u670b\u53cb\u53ef\u4ee5\u501f\u9274\u53c2\u8003\u4e0b\uff0c\u5e0c\u671b\u80fd\u591f\u6709\u6240\u5e2e\u52a9\uff0c\u795d\u5927\u5bb6\u591a\u591a\u8fdb\u6b65\uff0c\u65e9\u65e5\u5347\u804c\u52a0\u85aa<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\u6b63\u6587<\/strong><\/div>\n

\"\"<\/p>\n

\u4e00\u4e2a\u7528\u4e8eReact\u7684\u53ef\u5b9a\u5236\u7684\u9ed1\u6697\u6a21\u5f0f\u5207\u6362\u5f00\u5173\u7ec4\u4ef6\u3002<\/p>\n

\u5982\u4f55\u4f7f\u7528\u5b83\u3002<\/strong><\/div>\n
1.\u5b89\u88c5\u548c\u4e0b\u8f7d<\/strong><\/span><\/div>\n
npm install @anatoliygatt\/dark-mode-toggle @emotion\/react @emotion\/styled<\/pre>\n
2.\u5bfc\u5165DarkModeToggle\u7ec4\u4ef6<\/strong><\/span><\/div>\n
import { useState } from 'react';\r\nimport { DarkModeToggle } from '@anatoliygatt\/dark-mode-toggle';<\/pre>\n
3.\u5c06\u9ed1\u6697\u6a21\u5f0f\u5207\u6362\u6dfb\u52a0\u5230\u5e94\u7528\u7a0b\u5e8f\u4e2d<\/strong><\/span><\/div>\n
function Example() {\r\n  const [mode, setMode] = useState('dark');\r\n  return (\r\n     {\r\n        setMode(mode);\r\n      }}\r\n    \/>\r\n  );\r\n}<\/darkmodetoggle><\/pre>\n
4.\u9ed8\u8ba4\u7684\u7ec4\u4ef6\u9053\u5177<\/strong><\/span><\/div>\n
mode = 'dark',\r\ndark,\r\nlight,\r\nonChange,\r\nsize = 'sm', \/\/ lg, md\r\ninactiveLabelColor = '#b9bdc1',\r\ninactiveLabelColorOnHover = '#fcfefe',\r\ninactiveLabelColorOnActive = '#cdd1d5',\r\nactiveLabelColor = '#5b5e62',\r\nactiveLabelColorOnHover = '#404346',\r\nactiveLabelColorOnActive = '#010101',\r\ninactiveTrackColor = '#dce0e3',\r\ninactiveTrackColorOnHover = '#fcfefe',\r\ninactiveTrackColorOnActive = '#cdd1d5',\r\nactiveTrackColor = '#404346',\r\nactiveTrackColorOnHover = '#2d2f31',\r\nactiveTrackColorOnActive = '#141516',\r\ninactiveThumbColor = '#2d2f31',\r\nactiveThumbColor = '#dce0e3',\r\nfocusRingColor = 'rgb(59 130 246 \/ 0.5)',\r\nariaLabel,<\/pre>\n
\u9884\u89c8<\/strong><\/div>\n

\"\"<\/p>\n

The postDark Mode Toggle Component For Reactappeared first onReactScript.<\/p>\n

\u4ee5\u4e0a\u5c31\u662fReact\u53ef\u5b9a\u5236\u9ed1\u6697\u6a21\u5f0f\u5207\u6362\u5f00\u5173\u7ec4\u4ef6\u7684\u8be6\u7ec6\u5185\u5bb9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u4e00\u4e2a\u7528\u4e8eReact\u7684\u53ef\u5b9a\u5236\u7684\u9ed1\u6697\u6a21\u5f0f\u5207\u6362\u5f00\u5173\u7ec4\u4ef6\u3002 npm install @anatoliygatt\/dar […]<\/p>\n","protected":false},"author":362,"featured_media":119570,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-256087","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/256087","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/362"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=256087"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/256087\/revisions"}],"predecessor-version":[{"id":256306,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/256087\/revisions\/256306"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/119570"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=256087"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=256087"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=256087"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}