vant/static/js/async/4629.22ec4564.js
2024-04-20 08:49:23 +00:00

2 lines
28 KiB
JavaScript

/*! For license information please see 4629.22ec4564.js.LICENSE.txt */
(self.webpackChunk=self.webpackChunk||[]).push([["4629"],{40963:function(s,a,n){"use strict";n.r(a);var l=n("80681");let t=["innerHTML"];a.default={setup:()=>({html:""}),render:()=>((0,l.wg)(),(0,l.iD)("div",{class:"van-doc-markdown-body",innerHTML:'<h1>ConfigProvider \u5168\u5C40\u914D\u7F6E</h1>\n<div class="van-doc-card"><h3 id="jie-shao" tabindex="-1">\u4ECB\u7ECD</h3>\n<p>\u7528\u4E8E\u5168\u5C40\u914D\u7F6E Vant \u7EC4\u4EF6\uFF0C\u63D0\u4F9B\u6DF1\u8272\u6A21\u5F0F\u3001\u4E3B\u9898\u5B9A\u5236\u7B49\u80FD\u529B\u3002</p>\n</div><div class="van-doc-card"><h3 id="yin-ru" tabindex="-1">\u5F15\u5165</h3>\n<p>\u901A\u8FC7\u4EE5\u4E0B\u65B9\u5F0F\u6765\u5168\u5C40\u6CE8\u518C\u7EC4\u4EF6\uFF0C\u66F4\u591A\u6CE8\u518C\u65B9\u5F0F\u8BF7\u53C2\u8003<a href="#/zh-CN/advanced-usage#zu-jian-zhu-ce" target="_blank">\u7EC4\u4EF6\u6CE8\u518C</a>\u3002</p>\n<pre><code class="language-js"><span class="hljs-keyword">import</span> { createApp } <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;vue&#x27;</span>;\n<span class="hljs-keyword">import</span> { <span class="hljs-title class_">ConfigProvider</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;vant&#x27;</span>;\n\n<span class="hljs-keyword">const</span> app = <span class="hljs-title function_">createApp</span>();\napp.<span class="hljs-title function_">use</span>(<span class="hljs-title class_">ConfigProvider</span>);\n</code></pre>\n</div><h2 id="shen-se-mo-shi" tabindex="-1">\u6DF1\u8272\u6A21\u5F0F</h2>\n<div class="van-doc-card"><h3 id="kai-qi-shen-se-mo-shi" tabindex="-1">\u5F00\u542F\u6DF1\u8272\u6A21\u5F0F</h3>\n<p>\u5C06 ConfigProvider \u7EC4\u4EF6\u7684 <code>theme</code> \u5C5E\u6027\u8BBE\u7F6E\u4E3A <code>dark</code>\uFF0C\u53EF\u4EE5\u5F00\u542F\u6DF1\u8272\u6A21\u5F0F\u3002</p>\n<p>\u6DF1\u8272\u6A21\u5F0F\u4F1A\u5168\u5C40\u751F\u6548\uFF0C\u4F7F\u9875\u9762\u4E0A\u7684\u6240\u6709 Vant \u7EC4\u4EF6\u53D8\u4E3A\u6DF1\u8272\u98CE\u683C\u3002</p>\n<pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">van-config-provider</span> <span class="hljs-attr">theme</span>=<span class="hljs-string">&quot;dark&quot;</span>&gt;</span>...<span class="hljs-tag">&lt;/<span class="hljs-name">van-config-provider</span>&gt;</span>\n</code></pre>\n<p>\u503C\u5F97\u6CE8\u610F\u7684\u662F\uFF0C\u5F00\u542F Vant \u7684\u6DF1\u8272\u6A21\u5F0F\u53EA\u4F1A\u5F71\u54CD Vant \u7EC4\u4EF6\u7684 UI\uFF0C\u5E76\u4E0D\u4F1A\u5F71\u54CD\u5168\u5C40\u7684\u6587\u5B57\u989C\u8272\u6216\u80CC\u666F\u989C\u8272\uFF0C\u4F60\u53EF\u4EE5\u53C2\u8003\u4EE5\u4E0B CSS \u6765\u8BBE\u7F6E\u4E00\u4E9B\u5168\u5C40\u6837\u5F0F\uFF1A</p>\n<pre><code class="language-css"><span class="hljs-selector-class">.van-theme-dark</span> <span class="hljs-selector-tag">body</span> {\n <span class="hljs-attribute">color</span>: <span class="hljs-number">#f5f5f5</span>;\n <span class="hljs-attribute">background-color</span>: black;\n}\n</code></pre>\n</div><div class="van-doc-card"><h3 id="dong-tai-qie-huan" tabindex="-1">\u52A8\u6001\u5207\u6362</h3>\n<p>\u901A\u8FC7\u52A8\u6001\u8BBE\u7F6E <code>theme</code> \u5C5E\u6027\uFF0C\u53EF\u4EE5\u5728\u6D45\u8272\u98CE\u683C\u548C\u6DF1\u8272\u98CE\u683C\u4E4B\u95F4\u8FDB\u884C\u5207\u6362\u3002</p>\n<pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">van-config-provider</span> <span class="hljs-attr">:theme</span>=<span class="hljs-string">&quot;theme&quot;</span>&gt;</span>...<span class="hljs-tag">&lt;/<span class="hljs-name">van-config-provider</span>&gt;</span>\n</code></pre>\n<pre><code class="language-js"><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {\n <span class="hljs-title function_">setup</span>(<span class="hljs-params"></span>) {\n <span class="hljs-keyword">const</span> theme = <span class="hljs-title function_">ref</span>(<span class="hljs-string">&#x27;light&#x27;</span>);\n\n <span class="hljs-built_in">setTimeout</span>(<span class="hljs-function">() =&gt;</span> {\n theme.<span class="hljs-property">value</span> = <span class="hljs-string">&#x27;dark&#x27;</span>;\n }, <span class="hljs-number">1000</span>);\n\n <span class="hljs-keyword">return</span> { theme };\n },\n};\n</code></pre>\n</div><h2 id="ding-zhi-zhu-ti" tabindex="-1">\u5B9A\u5236\u4E3B\u9898</h2>\n<div class="van-doc-card"><h3 id="jie-shao-1" tabindex="-1">\u4ECB\u7ECD</h3>\n<p>Vant \u7EC4\u4EF6\u901A\u8FC7\u4E30\u5BCC\u7684 <a href="https://developer.mozilla.org/zh-CN/docs/Web/CSS/Using_CSS_custom_properties" target="_blank">CSS \u53D8\u91CF</a> \u6765\u7EC4\u7EC7\u6837\u5F0F\uFF0C\u901A\u8FC7\u8986\u76D6\u8FD9\u4E9B CSS \u53D8\u91CF\uFF0C\u53EF\u4EE5\u5B9E\u73B0<strong>\u5B9A\u5236\u4E3B\u9898\u3001\u52A8\u6001\u5207\u6362\u4E3B\u9898</strong>\u7B49\u6548\u679C\u3002</p>\n<h4 id="shi-li" tabindex="-1">\u793A\u4F8B</h4>\n<p>\u4EE5 Button \u7EC4\u4EF6\u4E3A\u4F8B\uFF0C\u67E5\u770B\u7EC4\u4EF6\u7684\u6837\u5F0F\uFF0C\u53EF\u4EE5\u770B\u5230 <code>.van-button--primary</code> \u7C7B\u540D\u4E0A\u5B58\u5728\u4EE5\u4E0B\u53D8\u91CF\uFF1A</p>\n<pre><code class="language-css"><span class="hljs-selector-class">.van-button--primary</span> {\n <span class="hljs-attribute">color</span>: <span class="hljs-built_in">var</span>(--van-button-primary-color);\n <span class="hljs-attribute">background-color</span>: <span class="hljs-built_in">var</span>(--van-button-primary-background);\n}\n</code></pre>\n<p>\u8FD9\u4E9B\u53D8\u91CF\u7684\u9ED8\u8BA4\u503C\u88AB\u5B9A\u4E49\u5728 <code>:root</code> \u8282\u70B9\u4E0A\uFF0CHTML \u91CC\u7684\u6240\u6709\u5B50\u8282\u70B9\u90FD\u53EF\u4EE5\u8BBF\u95EE\u5230\u8FD9\u4E9B\u53D8\u91CF\uFF1A</p>\n<pre><code class="language-css"><span class="hljs-selector-pseudo">:root</span> {\n <span class="hljs-attr">--van-white</span>: <span class="hljs-number">#fff</span>;\n <span class="hljs-attr">--van-blue</span>: <span class="hljs-number">#1989fa</span>;\n <span class="hljs-attr">--van-button-primary-color</span>: <span class="hljs-built_in">var</span>(--van-white);\n <span class="hljs-attr">--van-button-primary-background</span>: <span class="hljs-built_in">var</span>(--van-primary-color);\n}\n</code></pre>\n</div><div class="van-doc-card"><h3 id="zi-ding-yi-css-bian-liang" tabindex="-1">\u81EA\u5B9A\u4E49 CSS \u53D8\u91CF</h3>\n<h4 id="tong-guo-css-fu-gai" tabindex="-1">\u901A\u8FC7 CSS \u8986\u76D6</h4>\n<p>\u4F60\u53EF\u4EE5\u76F4\u63A5\u5728\u4EE3\u7801\u4E2D\u8986\u76D6\u8FD9\u4E9B CSS \u53D8\u91CF\uFF0CButton \u7EC4\u4EF6\u7684\u6837\u5F0F\u4F1A\u968F\u4E4B\u53D1\u751F\u6539\u53D8\uFF1A</p>\n<pre><code class="language-css"><span class="hljs-comment">/* \u6DFB\u52A0\u8FD9\u6BB5\u6837\u5F0F\u540E\uFF0CPrimary Button \u4F1A\u53D8\u6210\u7EA2\u8272 */</span>\n<span class="hljs-selector-pseudo">:root</span><span class="hljs-selector-pseudo">:root</span> {\n <span class="hljs-attr">--van-button-primary-background</span>: red;\n}\n</code></pre>\n<blockquote>\n<p>\u6CE8\u610F\uFF1A\u4E3A\u4EC0\u4E48\u8981\u5199\u4E24\u4E2A\u91CD\u590D\u7684 <code>:root</code>\uFF1F</p>\n<p>\u7531\u4E8E vant \u4E2D\u7684\u4E3B\u9898\u53D8\u91CF\u4E5F\u662F\u5728 <code>:root</code> \u4E0B\u58F0\u660E\u7684\uFF0C\u6240\u4EE5\u5728\u6709\u4E9B\u60C5\u51B5\u4E0B\u4F1A\u7531\u4E8E\u4F18\u5148\u7EA7\u7684\u95EE\u9898\u65E0\u6CD5\u6210\u529F\u8986\u76D6\u3002\u901A\u8FC7 <code>:root:root</code> \u53EF\u4EE5\u663E\u5F0F\u5730\u8BA9\u4F60\u6240\u5199\u5185\u5BB9\u7684\u4F18\u5148\u7EA7\u66F4\u9AD8\u4E00\u4E9B\uFF0C\u4ECE\u800C\u786E\u4FDD\u4E3B\u9898\u53D8\u91CF\u7684\u6210\u529F\u8986\u76D6\u3002</p>\n</blockquote>\n<h4 id="tong-guo-configprovider-fu-gai" tabindex="-1">\u901A\u8FC7 ConfigProvider \u8986\u76D6</h4>\n<p><code>ConfigProvider</code> \u7EC4\u4EF6\u63D0\u4F9B\u4E86\u8986\u76D6 CSS \u53D8\u91CF\u7684\u80FD\u529B\uFF0C\u4F60\u9700\u8981\u5728\u6839\u8282\u70B9\u5305\u88F9\u4E00\u4E2A <code>ConfigProvider</code> \u7EC4\u4EF6\uFF0C\u5E76\u901A\u8FC7 <code>theme-vars</code> \u5C5E\u6027\u6765\u914D\u7F6E\u4E00\u4E9B\u4E3B\u9898\u53D8\u91CF\u3002</p>\n<pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">van-config-provider</span> <span class="hljs-attr">:theme-vars</span>=<span class="hljs-string">&quot;themeVars&quot;</span>&gt;</span>\n <span class="hljs-tag">&lt;<span class="hljs-name">van-form</span>&gt;</span>\n <span class="hljs-tag">&lt;<span class="hljs-name">van-field</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;rate&quot;</span> <span class="hljs-attr">label</span>=<span class="hljs-string">&quot;\u8BC4\u5206&quot;</span>&gt;</span>\n <span class="hljs-tag">&lt;<span class="hljs-name">template</span> #<span class="hljs-attr">input</span>&gt;</span>\n <span class="hljs-tag">&lt;<span class="hljs-name">van-rate</span> <span class="hljs-attr">v-model</span>=<span class="hljs-string">&quot;rate&quot;</span> /&gt;</span>\n <span class="hljs-tag">&lt;/<span class="hljs-name">template</span>&gt;</span>\n <span class="hljs-tag">&lt;/<span class="hljs-name">van-field</span>&gt;</span>\n <span class="hljs-tag">&lt;<span class="hljs-name">van-field</span> <span class="hljs-attr">name</span>=<span class="hljs-string">&quot;slider&quot;</span> <span class="hljs-attr">label</span>=<span class="hljs-string">&quot;\u6ED1\u5757&quot;</span>&gt;</span>\n <span class="hljs-tag">&lt;<span class="hljs-name">template</span> #<span class="hljs-attr">input</span>&gt;</span>\n <span class="hljs-tag">&lt;<span class="hljs-name">van-slider</span> <span class="hljs-attr">v-model</span>=<span class="hljs-string">&quot;slider&quot;</span> /&gt;</span>\n <span class="hljs-tag">&lt;/<span class="hljs-name">template</span>&gt;</span>\n <span class="hljs-tag">&lt;/<span class="hljs-name">van-field</span>&gt;</span>\n <span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">style</span>=<span class="hljs-string">&quot;margin: 16px&quot;</span>&gt;</span>\n <span class="hljs-tag">&lt;<span class="hljs-name">van-button</span> <span class="hljs-attr">round</span> <span class="hljs-attr">block</span> <span class="hljs-attr">type</span>=<span class="hljs-string">&quot;primary&quot;</span> <span class="hljs-attr">native-type</span>=<span class="hljs-string">&quot;submit&quot;</span>&gt;</span>\n \u63D0\u4EA4\n <span class="hljs-tag">&lt;/<span class="hljs-name">van-button</span>&gt;</span>\n <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>\n <span class="hljs-tag">&lt;/<span class="hljs-name">van-form</span>&gt;</span>\n<span class="hljs-tag">&lt;/<span class="hljs-name">van-config-provider</span>&gt;</span>\n</code></pre>\n<pre><code class="language-js"><span class="hljs-keyword">import</span> { ref, reactive } <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;vue&#x27;</span>;\n\n<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {\n <span class="hljs-title function_">setup</span>(<span class="hljs-params"></span>) {\n <span class="hljs-keyword">const</span> rate = <span class="hljs-title function_">ref</span>(<span class="hljs-number">4</span>);\n <span class="hljs-keyword">const</span> slider = <span class="hljs-title function_">ref</span>(<span class="hljs-number">50</span>);\n\n <span class="hljs-comment">// themeVars \u5185\u7684\u503C\u4F1A\u88AB\u8F6C\u6362\u6210\u5BF9\u5E94 CSS \u53D8\u91CF</span>\n <span class="hljs-comment">// \u6BD4\u5982 sliderBarHeight \u4F1A\u8F6C\u6362\u6210 `--van-slider-bar-height`</span>\n <span class="hljs-keyword">const</span> themeVars = <span class="hljs-title function_">reactive</span>({\n <span class="hljs-attr">rateIconFullColor</span>: <span class="hljs-string">&#x27;#07c160&#x27;</span>,\n <span class="hljs-attr">sliderBarHeight</span>: <span class="hljs-string">&#x27;4px&#x27;</span>,\n <span class="hljs-attr">sliderButtonWidth</span>: <span class="hljs-string">&#x27;20px&#x27;</span>,\n <span class="hljs-attr">sliderButtonHeight</span>: <span class="hljs-string">&#x27;20px&#x27;</span>,\n <span class="hljs-attr">sliderActiveBackground</span>: <span class="hljs-string">&#x27;#07c160&#x27;</span>,\n <span class="hljs-attr">buttonPrimaryBackground</span>: <span class="hljs-string">&#x27;#07c160&#x27;</span>,\n <span class="hljs-attr">buttonPrimaryBorderColor</span>: <span class="hljs-string">&#x27;#07c160&#x27;</span>,\n });\n\n <span class="hljs-keyword">return</span> {\n rate,\n slider,\n themeVars,\n };\n },\n};\n</code></pre>\n<h4 id="css-bian-liang-sheng-xiao-fan-wei" tabindex="-1">CSS \u53D8\u91CF\u751F\u6548\u8303\u56F4</h4>\n<p>\u9ED8\u8BA4\u60C5\u51B5\u4E0B\uFF0CthemeVars \u4EA7\u751F\u7684 CSS \u53D8\u91CF\u662F\u8BBE\u7F6E\u5728\u7EC4\u4EF6\u6839\u8282\u70B9\u4E0A\u7684\uFF0C\u56E0\u6B64\u53EA\u4F1A\u5F71\u54CD\u5B83\u7684\u5B50\u7EC4\u4EF6\u7684\u6837\u5F0F\uFF0C\u4E0D\u4F1A\u5F71\u54CD\u6574\u4E2A\u9875\u9762\u3002</p>\n<p>\u4F60\u53EF\u4EE5\u901A\u8FC7 <code>theme-vars-scope</code> \u5C5E\u6027\u6765\u4FEE\u6539 CSS \u53D8\u91CF\u7684\u751F\u6548\u8303\u56F4\u3002\u6BD4\u5982\u5C06 <code>theme-vars-scope</code> \u8BBE\u7F6E\u4E3A <code>global</code>\uFF0C\u6B64\u65F6 themeVars \u4EA7\u751F\u7684 CSS \u53D8\u91CF\u4F1A\u8BBE\u7F6E\u5230 HTML \u7684\u6839\u8282\u70B9\uFF0C\u5E76\u5BF9\u6574\u4E2A\u9875\u9762\u5185\u7684\u6240\u6709\u7EC4\u4EF6\u751F\u6548\u3002</p>\n<pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">van-config-provider</span> <span class="hljs-attr">:theme-vars</span>=<span class="hljs-string">&quot;themeVars&quot;</span> <span class="hljs-attr">theme-vars-scope</span>=<span class="hljs-string">&quot;global&quot;</span>&gt;</span>\n ...\n<span class="hljs-tag">&lt;/<span class="hljs-name">van-config-provider</span>&gt;</span>\n</code></pre>\n<h4 id="zai-typescript-zhong-shi-yong" tabindex="-1">\u5728 TypeScript \u4E2D\u4F7F\u7528</h4>\n<p>\u5728 TypeScript \u4E2D\u5B9A\u4E49 themeVars \u65F6\uFF0C\u5EFA\u8BAE\u4F7F\u7528 Vant \u63D0\u4F9B\u7684 <code>ConfigProviderThemeVars</code> \u7C7B\u578B\uFF0C\u53EF\u4EE5\u63D0\u4F9B\u5B8C\u5584\u7684\u7C7B\u578B\u63D0\u793A\uFF1A</p>\n<pre><code class="language-ts"><span class="hljs-keyword">import</span> <span class="hljs-keyword">type</span> { <span class="hljs-title class_">ConfigProviderThemeVars</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;vant&#x27;</span>;\n\n<span class="hljs-keyword">const</span> <span class="hljs-attr">themeVars</span>: <span class="hljs-title class_">ConfigProviderThemeVars</span> = {\n <span class="hljs-attr">sliderBarHeight</span>: <span class="hljs-string">&#x27;4px&#x27;</span>,\n};\n</code></pre>\n</div><div class="van-doc-card"><h3 id="jie-he-shen-se-mo-shi-yu-css-bian-liang" tabindex="-1">\u7ED3\u5408\u6DF1\u8272\u6A21\u5F0F\u4E0E CSS \u53D8\u91CF</h3>\n<p>\u5982\u679C\u9700\u8981\u5355\u72EC\u5B9A\u4E49\u6DF1\u8272\u6A21\u5F0F\u6216\u6D45\u8272\u6A21\u5F0F\u4E0B\u7684 CSS \u53D8\u91CF\uFF0C\u53EF\u4EE5\u4F7F\u7528 <code>theme-vars-dark</code> \u548C <code>theme-vars-light</code> \u5C5E\u6027\u3002</p>\n<ul>\n<li><code>theme-vars-dark</code>: \u4EC5\u5728\u6DF1\u8272\u6A21\u5F0F\u4E0B\u751F\u6548\u7684 CSS \u53D8\u91CF\uFF0C\u4F18\u5148\u7EA7\u9AD8\u4E8E <code>theme-vars</code> \u4E2D\u5B9A\u4E49\u7684\u53D8\u91CF\u3002</li>\n<li><code>theme-vars-light</code>: \u4EC5\u5728\u6D45\u8272\u6A21\u5F0F\u4E0B\u751F\u6548\u7684 CSS \u53D8\u91CF\uFF0C\u4F18\u5148\u7EA7\u9AD8\u4E8E <code>theme-vars</code> \u4E2D\u5B9A\u4E49\u7684\u53D8\u91CF\u3002</li>\n</ul>\n<h4 id="shi-li-1" tabindex="-1">\u793A\u4F8B</h4>\n<p>\u4EE5\u4E0B\u65B9\u7684 <code>buttonPrimaryBackground</code> \u53D8\u91CF\u4E3A\u4F8B, \u5728\u6DF1\u8272\u6A21\u5F0F\u4E0B\u7684\u503C\u4E3A <code>blue</code>\uFF0C\u5728\u6D45\u8272\u6A21\u5F0F\u4E0B\u7684\u503C\u4E3A <code>green</code>\u3002</p>\n<pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">van-config-provider</span>\n <span class="hljs-attr">:theme-vars</span>=<span class="hljs-string">&quot;themeVars&quot;</span>\n <span class="hljs-attr">:theme-vars-dark</span>=<span class="hljs-string">&quot;themeVarsDark&quot;</span>\n <span class="hljs-attr">:theme-vars-light</span>=<span class="hljs-string">&quot;themeVarsLight&quot;</span>\n&gt;</span>\n ...\n<span class="hljs-tag">&lt;/<span class="hljs-name">van-config-provider</span>&gt;</span>\n</code></pre>\n<pre><code class="language-js"><span class="hljs-keyword">import</span> { ref, reactive } <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;vue&#x27;</span>;\n\n<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {\n <span class="hljs-title function_">setup</span>(<span class="hljs-params"></span>) {\n <span class="hljs-keyword">const</span> themeVars = <span class="hljs-title function_">reactive</span>({ <span class="hljs-attr">buttonPrimaryBackground</span>: <span class="hljs-string">&#x27;red&#x27;</span> });\n <span class="hljs-keyword">const</span> themeVarsDark = <span class="hljs-title function_">reactive</span>({ <span class="hljs-attr">buttonPrimaryBackground</span>: <span class="hljs-string">&#x27;blue&#x27;</span> });\n <span class="hljs-keyword">const</span> themeVarsLight = <span class="hljs-title function_">reactive</span>({ <span class="hljs-attr">buttonPrimaryBackground</span>: <span class="hljs-string">&#x27;green&#x27;</span> });\n\n <span class="hljs-keyword">return</span> {\n themeVars,\n themeVarsDark,\n themeVarsLight,\n };\n },\n};\n</code></pre>\n<h4 id="shi-yong-lei-ming" tabindex="-1">\u4F7F\u7528\u7C7B\u540D</h4>\n<p>\u6B64\u5916\uFF0C\u4F60\u4E5F\u53EF\u4EE5\u4F7F\u7528 <code>.van-theme-light</code> \u548C <code>.van-theme-dark</code> \u8FD9\u4E24\u4E2A\u7C7B\u540D\u9009\u62E9\u5668\u6765\u5355\u72EC\u4FEE\u6539\u6D45\u8272\u6216\u6DF1\u8272\u6A21\u5F0F\u4E0B\u7684\u57FA\u7840\u53D8\u91CF\u548C\u7EC4\u4EF6\u53D8\u91CF\u3002</p>\n<pre><code class="language-css"><span class="hljs-selector-class">.van-theme-light</span> {\n <span class="hljs-attr">--van-white</span>: white;\n}\n\n<span class="hljs-selector-class">.van-theme-dark</span> {\n <span class="hljs-attr">--van-white</span>: black;\n}\n</code></pre>\n</div><h2 id="zhu-ti-bian-liang" tabindex="-1">\u4E3B\u9898\u53D8\u91CF</h2>\n<div class="van-doc-card"><h3 id="bian-liang-lei-xing" tabindex="-1">\u53D8\u91CF\u7C7B\u578B</h3>\n<p>Vant \u4E2D\u7684 CSS \u53D8\u91CF\u5206\u4E3A <strong>\u57FA\u7840\u53D8\u91CF</strong> \u548C <strong>\u7EC4\u4EF6\u53D8\u91CF</strong>\u3002\u7EC4\u4EF6\u53D8\u91CF\u4F1A\u7EE7\u627F\u57FA\u7840\u53D8\u91CF\uFF0C\u56E0\u6B64\u5728\u4FEE\u6539\u57FA\u7840\u53D8\u91CF\u540E\uFF0C\u4F1A\u5F71\u54CD\u6240\u6709\u76F8\u5173\u7684\u7EC4\u4EF6\u3002</p>\n<h4 id="xiu-gai-bian-liang" tabindex="-1">\u4FEE\u6539\u53D8\u91CF</h4>\n<p>CSS \u53D8\u91CF\u5B58\u5728\u7EE7\u627F\u5173\u7CFB\uFF0C\u7EC4\u4EF6\u53D8\u91CF\u4F1A\u5BFB\u627E\u6700\u8FD1\u7684\u7236\u7EA7\u57FA\u7840\u53D8\u91CF\u8FDB\u884C\u7EE7\u627F\u3002</p>\n<p>\u56E0\u6B64\u4FEE\u6539\u57FA\u7840\u53D8\u91CF\u5B58\u5728\u4E00\u5B9A\u9650\u5236\uFF0C\u4F60\u9700\u8981\u4F7F\u7528 <code>:root</code> \u9009\u62E9\u5668\u6216 ConfigProvider \u7EC4\u4EF6\u7684 global \u6A21\u5F0F\u6765\u4FEE\u6539\u57FA\u7840\u53D8\u91CF\u3002\u5426\u5219\uFF0C\u7EC4\u4EF6\u53D8\u91CF\u53EF\u80FD\u4F1A\u65E0\u6CD5\u6B63\u786E\u7EE7\u627F\u57FA\u7840\u53D8\u91CF\u3002</p>\n<p>\u4EE5 <code>--van-primary-color</code> \u8FD9\u4E2A\u57FA\u7840\u53D8\u91CF\u4E3A\u4F8B\uFF1A</p>\n<ul>\n<li>\u53EF\u4EE5\u901A\u8FC7 <code>:root</code> \u9009\u62E9\u5668\u4FEE\u6539\uFF1A</li>\n</ul>\n<pre><code class="language-css"><span class="hljs-selector-pseudo">:root</span> {\n <span class="hljs-attr">--van-primary-color</span>: red;\n}\n</code></pre>\n<ul>\n<li>\u53EF\u4EE5\u901A\u8FC7 ConfigProvider \u7EC4\u4EF6\u7684 global \u6A21\u5F0F\u4FEE\u6539\uFF1A</li>\n</ul>\n<pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">van-config-provider</span>\n <span class="hljs-attr">:theme-vars</span>=<span class="hljs-string">&quot;{ primaryColor: &#x27;red&#x27; }&quot;</span>\n <span class="hljs-attr">theme-vars-scope</span>=<span class="hljs-string">&quot;global&quot;</span>\n&gt;</span>\n ...\n<span class="hljs-tag">&lt;/<span class="hljs-name">van-config-provider</span>&gt;</span>\n</code></pre>\n<ul>\n<li>\u4E0D\u53EF\u4EE5\u901A\u8FC7 ConfigProvider \u7EC4\u4EF6\u9ED8\u8BA4\u7684 <code>local</code> \u6A21\u5F0F\u4FEE\u6539\uFF1A</li>\n</ul>\n<pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">van-config-provider</span> <span class="hljs-attr">:theme-vars</span>=<span class="hljs-string">&quot;{ primaryColor: &#x27;red&#x27; }&quot;</span>&gt;</span>\n ...\n<span class="hljs-tag">&lt;/<span class="hljs-name">van-config-provider</span>&gt;</span>\n</code></pre>\n<p>\u5BF9\u4E8E\u7EC4\u4EF6\u53D8\u91CF\uFF0C\u5219\u6CA1\u6709\u4E0A\u8FF0\u9650\u5236\uFF0C\u53EF\u4EE5\u901A\u8FC7\u4EFB\u610F\u65B9\u5F0F\u4FEE\u6539\u3002</p>\n</div><div class="van-doc-card"><h3 id="ji-chu-bian-liang-lie-biao" tabindex="-1">\u57FA\u7840\u53D8\u91CF\u5217\u8868</h3>\n<p>\u4E0B\u9762\u662F\u6240\u6709\u7684\u57FA\u7840\u53D8\u91CF\uFF1A</p>\n<pre><code class="language-less"><span class="hljs-comment">// Color Palette</span>\n<span class="hljs-attr">--van-black</span>: #000;\n<span class="hljs-attr">--van-white</span>: #fff;\n<span class="hljs-attr">--van-gray-1</span>: #f7f8fa;\n<span class="hljs-attr">--van-gray-2</span>: #f2f3f5;\n<span class="hljs-attr">--van-gray-3</span>: #ebedf0;\n<span class="hljs-attr">--van-gray-4</span>: #dcdee0;\n<span class="hljs-attr">--van-gray-5</span>: #c8c9cc;\n<span class="hljs-attr">--van-gray-6</span>: #969799;\n<span class="hljs-attr">--van-gray-7</span>: #646566;\n<span class="hljs-attr">--van-gray-8</span>: #323233;\n<span class="hljs-attr">--van-red</span>: #ee0a24;\n<span class="hljs-attr">--van-blue</span>: #1989fa;\n<span class="hljs-attr">--van-orange</span>: #ff976a;\n<span class="hljs-attr">--van-orange-dark</span>: #ed6a0c;\n<span class="hljs-attr">--van-orange-light</span>: #fffbe8;\n<span class="hljs-attr">--van-green</span>: #07c160;\n\n<span class="hljs-comment">// Gradient Colors</span>\n<span class="hljs-attr">--van-gradient-red</span>: linear-gradient(to <span class="hljs-attribute">right, #ff6034, #ee0a24);\n--van-gradient-orange</span>: <span class="hljs-built_in">linear-gradient</span>(to right, <span class="hljs-number">#ffd01e</span>, <span class="hljs-number">#ff8917</span>);\n\n<span class="hljs-comment">// Component Colors</span>\n<span class="hljs-attr">--van-primary-color</span>: var(<span class="hljs-attr">--van-blue</span>);\n<span class="hljs-attr">--van-success-color</span>: var(<span class="hljs-attr">--van-green</span>);\n<span class="hljs-attr">--van-danger-color</span>: var(<span class="hljs-attr">--van-red</span>);\n<span class="hljs-attr">--van-warning-color</span>: var(<span class="hljs-attr">--van-orange</span>);\n<span class="hljs-attr">--van-text-color</span>: var(<span class="hljs-attr">--van-gray-8</span>);\n<span class="hljs-attr">--van-text-color-2</span>: var(<span class="hljs-attr">--van-gray-6</span>);\n<span class="hljs-attr">--van-text-color-3</span>: var(<span class="hljs-attr">--van-gray-5</span>);\n<span class="hljs-attr">--van-active-color</span>: var(<span class="hljs-attr">--van-gray-2</span>);\n<span class="hljs-attr">--van-active-opacity</span>: 0.6;\n<span class="hljs-attr">--van-disabled-opacity</span>: 0.5;\n<span class="hljs-attr">--van-background</span>: var(<span class="hljs-attr">--van-gray-1</span>);\n<span class="hljs-attr">--van-background-2</span>: var(<span class="hljs-attr">--van-white</span>);\n\n<span class="hljs-comment">// Padding</span>\n<span class="hljs-attr">--van-padding-base</span>: 4px;\n<span class="hljs-attr">--van-padding-xs</span>: 8px;\n<span class="hljs-attr">--van-padding-sm</span>: 12px;\n<span class="hljs-attr">--van-padding-md</span>: 16px;\n<span class="hljs-attr">--van-padding-lg</span>: 24px;\n<span class="hljs-attr">--van-padding-xl</span>: 32px;\n\n<span class="hljs-comment">// Font</span>\n<span class="hljs-attr">--van-font-size-xs</span>: 10px;\n<span class="hljs-attr">--van-font-size-sm</span>: 12px;\n<span class="hljs-attr">--van-font-size-md</span>: 14px;\n<span class="hljs-attr">--van-font-size-lg</span>: 16px;\n<span class="hljs-attr">--van-font-bold</span>: 600;\n<span class="hljs-attr">--van-line-height-xs</span>: 14px;\n<span class="hljs-attr">--van-line-height-sm</span>: 18px;\n<span class="hljs-attr">--van-line-height-md</span>: 20px;\n<span class="hljs-attr">--van-line-height-lg</span>: 22px;\n<span class="hljs-attr">--van-base-font</span>: -apple-system, BlinkMacSystemFont, &#x27;Helvetica Neue&#x27;, Helvetica,\n Segoe UI, Arial, Roboto, &#x27;PingFang SC&#x27;, &#x27;miui&#x27;, &#x27;Hiragino Sans GB&#x27;, &#x27;Microsoft Yahei&#x27;,\n sans-serif;\n<span class="hljs-attr">--van-price-font</span>: Avenir-Heavy, PingFang SC, Helvetica Neue, Arial, sans-serif;\n\n<span class="hljs-comment">// Animation</span>\n<span class="hljs-attr">--van-duration-base</span>: 0.3s;\n<span class="hljs-attr">--van-duration-fast</span>: 0.2s;\n<span class="hljs-attr">--van-ease-out</span>: ease-out;\n<span class="hljs-attr">--van-ease-in</span>: ease-in;\n\n<span class="hljs-comment">// Border</span>\n<span class="hljs-attr">--van-border-color</span>: var(<span class="hljs-attr">--van-gray-3</span>);\n<span class="hljs-attr">--van-border-width</span>: 1px;\n<span class="hljs-attr">--van-radius-sm</span>: 2px;\n<span class="hljs-attr">--van-radius-md</span>: 4px;\n<span class="hljs-attr">--van-radius-lg</span>: 8px;\n<span class="hljs-attr">--van-radius-max</span>: 999px;\n</code></pre>\n<p>\u4F60\u53EF\u4EE5\u5728\u5404\u4E2A\u7EC4\u4EF6\u6587\u6863\u5E95\u90E8\u7684\u8868\u683C\u4E2D\u67E5\u770B\u7EC4\u4EF6\u53D8\u91CF\u3002</p>\n</div><h2 id="api" tabindex="-1">API</h2>\n<div class="van-doc-card"><h3 id="props" tabindex="-1">Props</h3>\n<table>\n<thead>\n<tr>\n<th>\u53C2\u6570</th>\n<th>\u8BF4\u660E</th>\n<th>\u7C7B\u578B</th>\n<th>\u9ED8\u8BA4\u503C</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>theme</td>\n<td>\u4E3B\u9898\u98CE\u683C\uFF0C\u8BBE\u7F6E\u4E3A <code>dark</code> \u6765\u5F00\u542F\u6DF1\u8272\u6A21\u5F0F\uFF0C\u5168\u5C40\u751F\u6548</td>\n<td><em>ConfigProviderTheme</em></td>\n<td><code>light</code></td>\n</tr>\n<tr>\n<td>theme-vars</td>\n<td>\u81EA\u5B9A\u4E49\u4E3B\u9898\u53D8\u91CF\uFF0C\u5C40\u90E8\u751F\u6548</td>\n<td><em>object</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>theme-vars-dark</td>\n<td>\u4EC5\u5728\u6DF1\u8272\u6A21\u5F0F\u4E0B\u751F\u6548\u7684\u4E3B\u9898\u53D8\u91CF\uFF0C\u4F18\u5148\u7EA7\u9AD8\u4E8E <code>theme-vars</code></td>\n<td><em>object</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>theme-vars-light</td>\n<td>\u4EC5\u5728\u6D45\u8272\u6A21\u5F0F\u4E0B\u751F\u6548\u7684\u4E3B\u9898\u53D8\u91CF\uFF0C\u4F18\u5148\u7EA7\u9AD8\u4E8E <code>theme-vars</code></td>\n<td><em>object</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>theme-vars-scope</td>\n<td>\u9ED8\u8BA4\u4EC5\u5F71\u54CD\u5B50\u7EC4\u4EF6\u7684\u6837\u5F0F\uFF0C\u8BBE\u7F6E\u4E3A <code>global</code> \u6574\u4E2A\u9875\u9762\u751F\u6548</td>\n<td><em>ConfigProviderThemeVarsScope</em></td>\n<td><code>local</code></td>\n</tr>\n<tr>\n<td>tag</td>\n<td>\u6839\u8282\u70B9\u5BF9\u5E94\u7684 HTML \u6807\u7B7E\u540D</td>\n<td><em>string</em></td>\n<td><code>div</code></td>\n</tr>\n<tr>\n<td>z-index</td>\n<td>\u8BBE\u7F6E\u6240\u6709\u5F39\u7A97\u7C7B\u7EC4\u4EF6\u7684 z-index\uFF0C\u8BE5\u5C5E\u6027\u5BF9\u5168\u5C40\u751F\u6548</td>\n<td><em>number</em></td>\n<td><code>2000</code></td>\n</tr>\n<tr>\n<td>icon-prefix</td>\n<td>\u6240\u6709\u56FE\u6807\u7684\u7C7B\u540D\u524D\u7F00\uFF0C\u7B49\u540C\u4E8E Icon \u7EC4\u4EF6\u7684 <a href="#/zh-CN/icon#props" target="_blank">class-prefix \u5C5E\u6027</a></td>\n<td><em>string</em></td>\n<td><code>van-icon</code></td>\n</tr>\n</tbody>\n</table>\n</div><div class="van-doc-card"><h3 id="lei-xing-ding-yi" tabindex="-1">\u7C7B\u578B\u5B9A\u4E49</h3>\n<p>\u7EC4\u4EF6\u5BFC\u51FA\u4EE5\u4E0B\u7C7B\u578B\u5B9A\u4E49\uFF1A</p>\n<pre><code class="language-ts"><span class="hljs-keyword">import</span> <span class="hljs-keyword">type</span> {\n <span class="hljs-title class_">ConfigProviderProps</span>,\n <span class="hljs-title class_">ConfigProviderTheme</span>,\n <span class="hljs-title class_">ConfigProviderThemeVars</span>,\n <span class="hljs-title class_">ConfigProviderThemeVarsScope</span>,\n} <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;vant&#x27;</span>;\n</code></pre>\n</div>'},null,8,t))}}}]);