/*! 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:'
\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
\n\u901A\u8FC7\u4EE5\u4E0B\u65B9\u5F0F\u6765\u5168\u5C40\u6CE8\u518C\u7EC4\u4EF6\uFF0C\u66F4\u591A\u6CE8\u518C\u65B9\u5F0F\u8BF7\u53C2\u8003\u7EC4\u4EF6\u6CE8\u518C\u3002
\nimport { createApp } from 'vue';\nimport { ConfigProvider } from 'vant';\n\nconst app = createApp();\napp.use(ConfigProvider);\n
\n\u5C06 ConfigProvider \u7EC4\u4EF6\u7684 theme
\u5C5E\u6027\u8BBE\u7F6E\u4E3A dark
\uFF0C\u53EF\u4EE5\u5F00\u542F\u6DF1\u8272\u6A21\u5F0F\u3002
\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
\n<van-config-provider theme="dark">...</van-config-provider>\n
\n\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
\n.van-theme-dark body {\n color: #f5f5f5;\n background-color: black;\n}\n
\n\u901A\u8FC7\u52A8\u6001\u8BBE\u7F6E theme
\u5C5E\u6027\uFF0C\u53EF\u4EE5\u5728\u6D45\u8272\u98CE\u683C\u548C\u6DF1\u8272\u98CE\u683C\u4E4B\u95F4\u8FDB\u884C\u5207\u6362\u3002
<van-config-provider :theme="theme">...</van-config-provider>\n
\nexport default {\n setup() {\n const theme = ref('light');\n\n setTimeout(() => {\n theme.value = 'dark';\n }, 1000);\n\n return { theme };\n },\n};\n
\nVant \u7EC4\u4EF6\u901A\u8FC7\u4E30\u5BCC\u7684 CSS \u53D8\u91CF \u6765\u7EC4\u7EC7\u6837\u5F0F\uFF0C\u901A\u8FC7\u8986\u76D6\u8FD9\u4E9B CSS \u53D8\u91CF\uFF0C\u53EF\u4EE5\u5B9E\u73B0\u5B9A\u5236\u4E3B\u9898\u3001\u52A8\u6001\u5207\u6362\u4E3B\u9898\u7B49\u6548\u679C\u3002
\n\u4EE5 Button \u7EC4\u4EF6\u4E3A\u4F8B\uFF0C\u67E5\u770B\u7EC4\u4EF6\u7684\u6837\u5F0F\uFF0C\u53EF\u4EE5\u770B\u5230 .van-button--primary
\u7C7B\u540D\u4E0A\u5B58\u5728\u4EE5\u4E0B\u53D8\u91CF\uFF1A
.van-button--primary {\n color: var(--van-button-primary-color);\n background-color: var(--van-button-primary-background);\n}\n
\n\u8FD9\u4E9B\u53D8\u91CF\u7684\u9ED8\u8BA4\u503C\u88AB\u5B9A\u4E49\u5728 :root
\u8282\u70B9\u4E0A\uFF0CHTML \u91CC\u7684\u6240\u6709\u5B50\u8282\u70B9\u90FD\u53EF\u4EE5\u8BBF\u95EE\u5230\u8FD9\u4E9B\u53D8\u91CF\uFF1A
:root {\n --van-white: #fff;\n --van-blue: #1989fa;\n --van-button-primary-color: var(--van-white);\n --van-button-primary-background: var(--van-primary-color);\n}\n
\n\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
\n/* \u6DFB\u52A0\u8FD9\u6BB5\u6837\u5F0F\u540E\uFF0CPrimary Button \u4F1A\u53D8\u6210\u7EA2\u8272 */\n:root:root {\n --van-button-primary-background: red;\n}\n
\n\n\n\u6CE8\u610F\uFF1A\u4E3A\u4EC0\u4E48\u8981\u5199\u4E24\u4E2A\u91CD\u590D\u7684
\n:root
\uFF1F\u7531\u4E8E vant \u4E2D\u7684\u4E3B\u9898\u53D8\u91CF\u4E5F\u662F\u5728
\n:root
\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:root:root
\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
ConfigProvider
\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 ConfigProvider
\u7EC4\u4EF6\uFF0C\u5E76\u901A\u8FC7 theme-vars
\u5C5E\u6027\u6765\u914D\u7F6E\u4E00\u4E9B\u4E3B\u9898\u53D8\u91CF\u3002
<van-config-provider :theme-vars="themeVars">\n <van-form>\n <van-field name="rate" label="\u8BC4\u5206">\n <template #input>\n <van-rate v-model="rate" />\n </template>\n </van-field>\n <van-field name="slider" label="\u6ED1\u5757">\n <template #input>\n <van-slider v-model="slider" />\n </template>\n </van-field>\n <div style="margin: 16px">\n <van-button round block type="primary" native-type="submit">\n \u63D0\u4EA4\n </van-button>\n </div>\n </van-form>\n</van-config-provider>\n
\nimport { ref, reactive } from 'vue';\n\nexport default {\n setup() {\n const rate = ref(4);\n const slider = ref(50);\n\n // themeVars \u5185\u7684\u503C\u4F1A\u88AB\u8F6C\u6362\u6210\u5BF9\u5E94 CSS \u53D8\u91CF\n // \u6BD4\u5982 sliderBarHeight \u4F1A\u8F6C\u6362\u6210 `--van-slider-bar-height`\n const themeVars = reactive({\n rateIconFullColor: '#07c160',\n sliderBarHeight: '4px',\n sliderButtonWidth: '20px',\n sliderButtonHeight: '20px',\n sliderActiveBackground: '#07c160',\n buttonPrimaryBackground: '#07c160',\n buttonPrimaryBorderColor: '#07c160',\n });\n\n return {\n rate,\n slider,\n themeVars,\n };\n },\n};\n
\n\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
\n\u4F60\u53EF\u4EE5\u901A\u8FC7 theme-vars-scope
\u5C5E\u6027\u6765\u4FEE\u6539 CSS \u53D8\u91CF\u7684\u751F\u6548\u8303\u56F4\u3002\u6BD4\u5982\u5C06 theme-vars-scope
\u8BBE\u7F6E\u4E3A global
\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
<van-config-provider :theme-vars="themeVars" theme-vars-scope="global">\n ...\n</van-config-provider>\n
\n\u5728 TypeScript \u4E2D\u5B9A\u4E49 themeVars \u65F6\uFF0C\u5EFA\u8BAE\u4F7F\u7528 Vant \u63D0\u4F9B\u7684 ConfigProviderThemeVars
\u7C7B\u578B\uFF0C\u53EF\u4EE5\u63D0\u4F9B\u5B8C\u5584\u7684\u7C7B\u578B\u63D0\u793A\uFF1A
import type { ConfigProviderThemeVars } from 'vant';\n\nconst themeVars: ConfigProviderThemeVars = {\n sliderBarHeight: '4px',\n};\n
\n\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 theme-vars-dark
\u548C theme-vars-light
\u5C5E\u6027\u3002
theme-vars-dark
: \u4EC5\u5728\u6DF1\u8272\u6A21\u5F0F\u4E0B\u751F\u6548\u7684 CSS \u53D8\u91CF\uFF0C\u4F18\u5148\u7EA7\u9AD8\u4E8E theme-vars
\u4E2D\u5B9A\u4E49\u7684\u53D8\u91CF\u3002theme-vars-light
: \u4EC5\u5728\u6D45\u8272\u6A21\u5F0F\u4E0B\u751F\u6548\u7684 CSS \u53D8\u91CF\uFF0C\u4F18\u5148\u7EA7\u9AD8\u4E8E theme-vars
\u4E2D\u5B9A\u4E49\u7684\u53D8\u91CF\u3002\u4EE5\u4E0B\u65B9\u7684 buttonPrimaryBackground
\u53D8\u91CF\u4E3A\u4F8B, \u5728\u6DF1\u8272\u6A21\u5F0F\u4E0B\u7684\u503C\u4E3A blue
\uFF0C\u5728\u6D45\u8272\u6A21\u5F0F\u4E0B\u7684\u503C\u4E3A green
\u3002
<van-config-provider\n :theme-vars="themeVars"\n :theme-vars-dark="themeVarsDark"\n :theme-vars-light="themeVarsLight"\n>\n ...\n</van-config-provider>\n
\nimport { ref, reactive } from 'vue';\n\nexport default {\n setup() {\n const themeVars = reactive({ buttonPrimaryBackground: 'red' });\n const themeVarsDark = reactive({ buttonPrimaryBackground: 'blue' });\n const themeVarsLight = reactive({ buttonPrimaryBackground: 'green' });\n\n return {\n themeVars,\n themeVarsDark,\n themeVarsLight,\n };\n },\n};\n
\n\u6B64\u5916\uFF0C\u4F60\u4E5F\u53EF\u4EE5\u4F7F\u7528 .van-theme-light
\u548C .van-theme-dark
\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
.van-theme-light {\n --van-white: white;\n}\n\n.van-theme-dark {\n --van-white: black;\n}\n
\nVant \u4E2D\u7684 CSS \u53D8\u91CF\u5206\u4E3A \u57FA\u7840\u53D8\u91CF \u548C \u7EC4\u4EF6\u53D8\u91CF\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
\nCSS \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
\n\u56E0\u6B64\u4FEE\u6539\u57FA\u7840\u53D8\u91CF\u5B58\u5728\u4E00\u5B9A\u9650\u5236\uFF0C\u4F60\u9700\u8981\u4F7F\u7528 :root
\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
\u4EE5 --van-primary-color
\u8FD9\u4E2A\u57FA\u7840\u53D8\u91CF\u4E3A\u4F8B\uFF1A
:root
\u9009\u62E9\u5668\u4FEE\u6539\uFF1A:root {\n --van-primary-color: red;\n}\n
\n<van-config-provider\n :theme-vars="{ primaryColor: 'red' }"\n theme-vars-scope="global"\n>\n ...\n</van-config-provider>\n
\nlocal
\u6A21\u5F0F\u4FEE\u6539\uFF1A<van-config-provider :theme-vars="{ primaryColor: 'red' }">\n ...\n</van-config-provider>\n
\n\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
\n\u4E0B\u9762\u662F\u6240\u6709\u7684\u57FA\u7840\u53D8\u91CF\uFF1A
\n// Color Palette\n--van-black: #000;\n--van-white: #fff;\n--van-gray-1: #f7f8fa;\n--van-gray-2: #f2f3f5;\n--van-gray-3: #ebedf0;\n--van-gray-4: #dcdee0;\n--van-gray-5: #c8c9cc;\n--van-gray-6: #969799;\n--van-gray-7: #646566;\n--van-gray-8: #323233;\n--van-red: #ee0a24;\n--van-blue: #1989fa;\n--van-orange: #ff976a;\n--van-orange-dark: #ed6a0c;\n--van-orange-light: #fffbe8;\n--van-green: #07c160;\n\n// Gradient Colors\n--van-gradient-red: linear-gradient(to right, #ff6034, #ee0a24);\n--van-gradient-orange: linear-gradient(to right, #ffd01e, #ff8917);\n\n// Component Colors\n--van-primary-color: var(--van-blue);\n--van-success-color: var(--van-green);\n--van-danger-color: var(--van-red);\n--van-warning-color: var(--van-orange);\n--van-text-color: var(--van-gray-8);\n--van-text-color-2: var(--van-gray-6);\n--van-text-color-3: var(--van-gray-5);\n--van-active-color: var(--van-gray-2);\n--van-active-opacity: 0.6;\n--van-disabled-opacity: 0.5;\n--van-background: var(--van-gray-1);\n--van-background-2: var(--van-white);\n\n// Padding\n--van-padding-base: 4px;\n--van-padding-xs: 8px;\n--van-padding-sm: 12px;\n--van-padding-md: 16px;\n--van-padding-lg: 24px;\n--van-padding-xl: 32px;\n\n// Font\n--van-font-size-xs: 10px;\n--van-font-size-sm: 12px;\n--van-font-size-md: 14px;\n--van-font-size-lg: 16px;\n--van-font-bold: 600;\n--van-line-height-xs: 14px;\n--van-line-height-sm: 18px;\n--van-line-height-md: 20px;\n--van-line-height-lg: 22px;\n--van-base-font: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica,\n Segoe UI, Arial, Roboto, 'PingFang SC', 'miui', 'Hiragino Sans GB', 'Microsoft Yahei',\n sans-serif;\n--van-price-font: Avenir-Heavy, PingFang SC, Helvetica Neue, Arial, sans-serif;\n\n// Animation\n--van-duration-base: 0.3s;\n--van-duration-fast: 0.2s;\n--van-ease-out: ease-out;\n--van-ease-in: ease-in;\n\n// Border\n--van-border-color: var(--van-gray-3);\n--van-border-width: 1px;\n--van-radius-sm: 2px;\n--van-radius-md: 4px;\n--van-radius-lg: 8px;\n--van-radius-max: 999px;\n
\n\u4F60\u53EF\u4EE5\u5728\u5404\u4E2A\u7EC4\u4EF6\u6587\u6863\u5E95\u90E8\u7684\u8868\u683C\u4E2D\u67E5\u770B\u7EC4\u4EF6\u53D8\u91CF\u3002
\n\u53C2\u6570 | \n\u8BF4\u660E | \n\u7C7B\u578B | \n\u9ED8\u8BA4\u503C | \n
---|---|---|---|
theme | \n\u4E3B\u9898\u98CE\u683C\uFF0C\u8BBE\u7F6E\u4E3A dark \u6765\u5F00\u542F\u6DF1\u8272\u6A21\u5F0F\uFF0C\u5168\u5C40\u751F\u6548 | \nConfigProviderTheme | \nlight | \n
theme-vars | \n\u81EA\u5B9A\u4E49\u4E3B\u9898\u53D8\u91CF\uFF0C\u5C40\u90E8\u751F\u6548 | \nobject | \n- | \n
theme-vars-dark | \n\u4EC5\u5728\u6DF1\u8272\u6A21\u5F0F\u4E0B\u751F\u6548\u7684\u4E3B\u9898\u53D8\u91CF\uFF0C\u4F18\u5148\u7EA7\u9AD8\u4E8E theme-vars | \nobject | \n- | \n
theme-vars-light | \n\u4EC5\u5728\u6D45\u8272\u6A21\u5F0F\u4E0B\u751F\u6548\u7684\u4E3B\u9898\u53D8\u91CF\uFF0C\u4F18\u5148\u7EA7\u9AD8\u4E8E theme-vars | \nobject | \n- | \n
theme-vars-scope | \n\u9ED8\u8BA4\u4EC5\u5F71\u54CD\u5B50\u7EC4\u4EF6\u7684\u6837\u5F0F\uFF0C\u8BBE\u7F6E\u4E3A global \u6574\u4E2A\u9875\u9762\u751F\u6548 | \nConfigProviderThemeVarsScope | \nlocal | \n
tag | \n\u6839\u8282\u70B9\u5BF9\u5E94\u7684 HTML \u6807\u7B7E\u540D | \nstring | \ndiv | \n
z-index | \n\u8BBE\u7F6E\u6240\u6709\u5F39\u7A97\u7C7B\u7EC4\u4EF6\u7684 z-index\uFF0C\u8BE5\u5C5E\u6027\u5BF9\u5168\u5C40\u751F\u6548 | \nnumber | \n2000 | \n
icon-prefix | \n\u6240\u6709\u56FE\u6807\u7684\u7C7B\u540D\u524D\u7F00\uFF0C\u7B49\u540C\u4E8E Icon \u7EC4\u4EF6\u7684 class-prefix \u5C5E\u6027 | \nstring | \nvan-icon | \n
\u7EC4\u4EF6\u5BFC\u51FA\u4EE5\u4E0B\u7C7B\u578B\u5B9A\u4E49\uFF1A
\nimport type {\n ConfigProviderProps,\n ConfigProviderTheme,\n ConfigProviderThemeVars,\n ConfigProviderThemeVarsScope,\n} from 'vant';\n
\n