mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
2 lines
22 KiB
JavaScript
2 lines
22 KiB
JavaScript
/*! For license information please see 3567.cafe3f30.js.LICENSE.txt */
|
|
(self.webpackChunk=self.webpackChunk||[]).push([["3567"],{21144:function(n,a,s){"use strict";s.r(a);var t=s("80681");let e=["innerHTML"];a.default={setup:()=>({html:""}),render:()=>((0,t.wg)(),(0,t.iD)("div",{class:"van-doc-markdown-body",innerHTML:'<h1>4.0 \u7248\u672C\u4ECB\u7ECD</h1>\n<div class="van-doc-card"><h3 id="yin-yan" tabindex="-1">\u5F15\u8A00</h3>\n<p>\u5386\u7ECF\u4E00\u5E74\u7684\u8FED\u4EE3\uFF0CVant 4.0 \u7248\u672C\u5DF2\u6B63\u5F0F\u53D1\u5E03\uFF0C\u8FD9\u662F Vant \u81EA 2017 \u5E74\u5F00\u6E90\u4EE5\u6765\u53D1\u5E03\u7684\u7B2C\u56DB\u4E2A\u91CD\u8981\u7248\u672C\u3002</p>\n<p>\u5728\u672C\u6B21\u8FED\u4EE3\u4E2D\uFF0CVant \u652F\u6301\u4E86\u6DF1\u8272\u6A21\u5F0F\uFF0C\u589E\u52A0\u4E94\u4E2A\u65B0\u7EC4\u4EF6\uFF0C\u6539\u5584\u5DE5\u5177\u51FD\u6570 API \u5E76\u91CD\u6784 Picker \u7B49\u7EC4\u4EF6\uFF0C\u540C\u65F6\u7EE7\u7EED\u5728\u8F7B\u91CF\u5316\u548C\u6613\u7528\u6027\u65B9\u9762\u505A\u51FA\u6539\u8FDB\u3002</p>\n</div><div class="van-doc-card"><h3 id="zhi-chi-shen-se-mo-shi" tabindex="-1">\u652F\u6301\u6DF1\u8272\u6A21\u5F0F</h3>\n<p><strong>Vant 4.0 \u652F\u6301\u5207\u6362\u6240\u6709\u7EC4\u4EF6\u4E3A\u6DF1\u8272\u6A21\u5F0F\u3002</strong></p>\n<p>\u53EA\u9700\u8981\u628A <a href="https://vant-ui.github.io/vant/#/zh-CN/config-provider" target="_blank">ConfigProvider \u7EC4\u4EF6</a>\u7684 <code>theme</code> \u5C5E\u6027\u8BBE\u7F6E\u4E3A <code>dark</code>\uFF0C\u5373\u53EF\u5207\u6362\u4E3A\u6DF1\u8272\u6A21\u5F0F\uFF0C\u5C06\u9875\u9762\u4E0A\u7684\u6240\u6709 Vant \u7EC4\u4EF6\u53D8\u6210\u6DF1\u8272\u98CE\u683C\u3002</p>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-config-provider</span> <span class="hljs-attr">theme</span>=<span class="hljs-string">"dark"</span>></span>\n <span class="hljs-comment"><!-- child components --></span>\n<span class="hljs-tag"></<span class="hljs-name">van-config-provider</span>></span>\n</code></pre>\n<p><img src="https://user-images.githubusercontent.com/7237365/205472724-6c9ee0df-df10-4f9b-84b6-081576bdcea9.png" alt=""></p>\n<p>\u540C\u65F6\uFF0CVant 4.0 \u6587\u6863\u4E5F\u5DF2\u652F\u6301\u5207\u6362\u4E3A\u6DF1\u8272\u6A21\u5F0F\uFF1A</p>\n<p><img src="https://user-images.githubusercontent.com/7237365/205472729-fefc9053-1866-4812-8b97-ee0ba5d47230.png" alt=""></p>\n</div><div class="van-doc-card"><h3 id="ji-ge-xin-zu-jian" tabindex="-1">\u51E0\u4E2A\u65B0\u7EC4\u4EF6</h3>\n<p><strong>Vant 4.0 \u5305\u542B\u4EE5\u4E0B\u65B0\u7EC4\u4EF6\uFF1A</strong></p>\n<ul>\n<li><a href="https://vant-ui.github.io/vant/#/zh-CN/back-top" target="_blank">BackTop \u56DE\u5230\u9876\u90E8</a>\uFF1A\u8FD4\u56DE\u9875\u9762\u9876\u90E8\u7684\u64CD\u4F5C\u6309\u94AE\u3002</li>\n<li><a href="https://vant-ui.github.io/vant/#/zh-CN/time-picker" target="_blank">TimePicker \u65F6\u95F4\u9009\u62E9\u5668</a>\uFF1A\u7528\u4E8E\u65F6\u95F4\u9009\u62E9\uFF0C\u5305\u62EC\u65F6\u3001\u5206\u3001\u79D2\u3002</li>\n<li><a href="https://vant-ui.github.io/vant/#/zh-CN/date-picker" target="_blank">DatePicker \u65E5\u671F\u9009\u62E9\u5668</a>\uFF1A\u7528\u4E8E\u65E5\u671F\u9009\u62E9\uFF0C\u5305\u62EC\u5E74\u3001\u6708\u3001\u65E5\u3002</li>\n<li><a href="https://vant-ui.github.io/vant/#/zh-CN/picker-group" target="_blank">PickerGroup \u9009\u62E9\u5668\u7EC4</a>\uFF1A\u7528\u4E8E\u7ED3\u5408\u591A\u4E2A Picker \u9009\u62E9\u5668\u7EC4\u4EF6\uFF0C\u5728\u4E00\u6B21\u4EA4\u4E92\u4E2D\u5B8C\u6210\u591A\u4E2A\u503C\u7684\u9009\u62E9\u3002</li>\n<li><a href="https://vant-ui.github.io/vant/#/zh-CN/skeleton" target="_blank">Skeleton \u9AA8\u67B6\u5C4F\u5B50\u7EC4\u4EF6</a>\uFF1A\u901A\u8FC7 SkeletonTitle\u3001SkeletonImage\u3001SkeletonAvatar \u7B49\u5B50\u7EC4\u4EF6\u6765\u81EA\u5B9A\u4E49\u9AA8\u67B6\u5C4F\u3002</li>\n</ul>\n<p>\u5176\u4E2D\uFF0CTimePicker \u548C DatePicker \u7531\u65E7\u7248\u7684 DatetimePicker \u7EC4\u4EF6\u62C6\u5206\u800C\u6765\uFF0CDatetimePicker \u7EC4\u4EF6\u4E0D\u518D\u63D0\u4F9B\u3002\u4F60\u53EF\u4EE5\u901A\u8FC7 PickerGroup \u6765\u5B9E\u73B0\u540C\u65F6\u9009\u62E9\u65E5\u671F\u548C\u65F6\u95F4\u7684\u4EA4\u4E92\u6548\u679C\u3002</p>\n<p><img src="https://user-images.githubusercontent.com/7237365/205474243-14e0a87c-dcfa-4229-9a16-f6ebf910b621.png" alt=""></p>\n</div><div class="van-doc-card"><h3 id="bao-chi-qing-liang" tabindex="-1">\u4FDD\u6301\u8F7B\u91CF</h3>\n<p><strong>Vant 4.0 \u7684\u5B89\u88C5\u4F53\u79EF\u964D\u4F4E 30%\uFF0C\u5305\u4F53\u79EF\u4FDD\u6301\u8F7B\u91CF\u3002</strong></p>\n<p>\u968F\u7740 npm \u751F\u6001\u7684\u53D1\u5C55\uFF0Cnode_modules \u6B63\u5728\u541E\u566C\u6211\u4EEC\u7684\u78C1\u76D8\u7A7A\u95F4\u3002\u4E3A\u4E86\u7F13\u89E3 node_modules \u9ED1\u6D1E\u3001\u52A0\u5FEB\u5B89\u88C5\u901F\u5EA6\uFF0C\u6211\u4EEC\u5BF9 Vant \u7684 npm \u4F9D\u8D56\u548C\u6784\u5EFA\u4EA7\u7269\u8FDB\u884C\u4E86\u4F18\u5316\u3002</p>\n<p>\u76F8\u8F83\u4E8E Vant 3.6.2 \u7248\u672C\uFF0CVant 4.0.0 \u7248\u672C\u7684\u5B89\u88C5\u4F53\u79EF\u7531 7MB \u4E0B\u964D\u81F3 5MB\u3002\u4F5C\u4E3A\u5BF9\u6BD4\uFF0C\u793E\u533A\u4E2D\u4E3B\u6D41\u7EC4\u4EF6\u5E93\u7684\u5B89\u88C5\u4F53\u79EF\u666E\u904D\u5728 15MB ~ 80MB\u3002\u4F60\u53EF\u4EE5\u901A\u8FC7 <a href="https://packagephobia.com/result?p=vant" target="_blank">packagephobia</a> \u6765\u67E5\u8BE2 npm \u5305\u7684\u5B89\u88C5\u4F53\u79EF\u3002</p>\n<p><img src="https://user-images.githubusercontent.com/7237365/205470714-e1828299-4df2-40f4-b7cc-f65971fe4567.png" alt=""></p>\n<p>\u5728\u5305\u4F53\u79EF\u4E0A\uFF0C\u672C\u6B21\u66F4\u65B0\u4F9D\u7136\u52A0\u91CF\u4E0D\u52A0\u4EF7\uFF0CMinified + Gzipped \u540E\u7684\u4F53\u79EF\u4FDD\u6301\u5728 70KB \u4EE5\u4E0B\uFF1A</p>\n<p><img src="https://user-images.githubusercontent.com/7237365/205474583-f2d8226f-e089-42d7-8326-3c874dcf1784.png" alt=""></p>\n</div><div class="van-doc-card"><h3 id="tong-yi-zhu-se-diao" tabindex="-1">\u7EDF\u4E00\u4E3B\u8272\u8C03</h3>\n<p><strong>Vant 4.0 \u7EDF\u4E00\u4E86\u6240\u6709\u7EC4\u4EF6\u7684\u4E3B\u8272\u8C03\u3002</strong></p>\n<p>\u5728\u4E4B\u524D\u7684\u7248\u672C\u4E2D\uFF0CVant \u7EC4\u4EF6\u6709\u4E24\u79CD\u4E3B\u8272\u8C03\uFF0C\u90E8\u5206\u7EC4\u4EF6\u91C7\u7528\u84DD\u8272 <code>#1989fa</code> \u4F5C\u4E3A\u4E3B\u8272\u8C03\uFF0C\u53E6\u4E00\u90E8\u5206\u5219\u91C7\u7528\u7EA2\u8272 <code>#ee0a24</code>\u3002</p>\n<p>\u4E3A\u4E86\u4FDD\u6301\u8272\u5F69\u89C4\u8303\u7684\u4E00\u81F4\u6027\uFF0C\u6211\u4EEC\u5728 Vant 4 \u4E2D\u5BF9\u4E3B\u8272\u8C03\u8FDB\u884C\u7EDF\u4E00\uFF0C\u6240\u6709\u7EC4\u4EF6\u5747\u91C7\u7528\u84DD\u8272\u4F5C\u4E3A\u4E3B\u8272\u8C03\u3002</p>\n<p><img src="https://user-images.githubusercontent.com/7237365/205472726-a0552833-f99d-447a-acce-051ec7ebdbe1.png" alt=""></p>\n<p>\u7EDF\u4E00\u4E3B\u8272\u8C03\u540E\uFF0C\u4E3B\u9898\u5B9A\u5236\u4F1A\u53D8\u5F97\u66F4\u52A0\u5BB9\u6613\u3002\u6BD4\u5982\uFF0C\u4F60\u53EF\u4EE5\u8986\u76D6 <code>--van-primary-color</code> \u8FD9\u4E2A CSS \u53D8\u91CF\uFF0C\u5C06\u6240\u6709\u7EC4\u4EF6\u7684\u4E3B\u8272\u8C03\u8BBE\u7F6E\u4E3A\u7EFF\u8272\uFF1A</p>\n<pre><code class="language-css"><span class="hljs-selector-pseudo">:root</span> {\n <span class="hljs-attr">--van-primary-color</span>: <span class="hljs-number">#07c160</span>;\n}\n</code></pre>\n</div><div class="van-doc-card"><h3 id="an-xu-yin-ru-fang-shi-diao-zheng" tabindex="-1">\u6309\u9700\u5F15\u5165\u65B9\u5F0F\u8C03\u6574</h3>\n<p><strong>Vant 4.0 \u4E0D\u518D\u4F7F\u7528 babel-plugin-import \u5B9E\u73B0\u6309\u9700\u5F15\u5165\u3002</strong></p>\n<p>\u5728\u65E9\u671F\uFF0C\u7EC4\u4EF6\u5E93\u5927\u591A\u4F7F\u7528 <code>babel-plugin-import</code> \u5B9E\u73B0\u6309\u9700\u5F15\u5165\uFF0C\u8FD9\u610F\u5473\u7740\u7EC4\u4EF6\u5E93\u4F1A\u5F3A\u4F9D\u8D56 Babel \u7F16\u8BD1\u3002\u4ECE Vant 4.0 \u5F00\u59CB\uFF0C\u5C06\u4E0D\u518D\u652F\u6301 <code>babel-plugin-import</code>\uFF0C\u4E3B\u8981\u5E26\u6765\u4EE5\u4E0B\u6536\u76CA\uFF1A</p>\n<ul>\n<li>\u4E0D\u518D\u5F3A\u4F9D\u8D56 Babel \u7F16\u8BD1\uFF0C\u9879\u76EE\u53EF\u4EE5\u4F7F\u7528 SWC\u3001esbuild \u7B49\u73B0\u4EE3\u7F16\u8BD1\u5DE5\u5177\uFF0C\u8FDB\u800C\u63D0\u5347\u7F16\u8BD1\u6548\u7387\u3002</li>\n</ul>\n<p><img src="https://user-images.githubusercontent.com/7237365/205478241-dba3c4ed-152c-4892-9e74-1a0d978be314.png" alt=""></p>\n<ul>\n<li>\u4E0D\u518D\u53D7\u5230 <code>babel-plugin-import</code> \u7684 import \u9650\u5236\uFF0C\u53EF\u4EE5\u4ECE Vant \u4E2D\u5BFC\u5165\u9664\u7EC4\u4EF6\u4EE5\u5916\u7684\u5185\u5BB9\uFF0C\u6BD4\u5982 Vant 4 \u4E2D\u65B0\u589E\u7684 <code>showToast</code> \u65B9\u6CD5\uFF0C\u6216\u662F <code>buttonProps</code> \u5BF9\u8C61\uFF1A</li>\n</ul>\n<pre><code class="language-ts"><span class="hljs-keyword">import</span> { showToast, buttonProps } <span class="hljs-keyword">from</span> <span class="hljs-string">'vant'</span>;\n</code></pre>\n<p>\u5728\u5305\u4F53\u79EF\u65B9\u9762\uFF0C\u79FB\u9664 <code>babel-plugin-import</code> \u5BF9\u9879\u76EE\u7684 JS \u4F53\u79EF\u4E0D\u4F1A\u6709\u5F71\u54CD\uFF0C\u56E0\u4E3A Vant \u9ED8\u8BA4\u652F\u6301\u901A\u8FC7 Tree Shaking \u6765\u79FB\u9664\u4E0D\u9700\u8981\u7684 JS \u4EE3\u7801\uFF0C\u800C CSS \u4EE3\u7801\u53EF\u4EE5\u901A\u8FC7 <a href="https://github.com/unplugin/unplugin-vue-components" target="_blank">unplugin-vue-components</a> \u63D2\u4EF6\u5B9E\u73B0\u6309\u9700\u5F15\u5165\uFF0C\u8BE6\u7EC6\u7528\u6CD5\u8BF7\u53C2\u8003 <a href="https://vant-ui.github.io/vant/#/zh-CN/quickstart" target="_blank">\u300C\u5FEB\u901F\u4E0A\u624B\u300D</a>\u3002</p>\n</div><div class="van-doc-card"><h3 id="yang-shi-bian-liang-lei-xing-ti-shi" tabindex="-1">\u6837\u5F0F\u53D8\u91CF\u7C7B\u578B\u63D0\u793A</h3>\n<p><strong>Vant 4.0 \u63D0\u4F9B\u4E86\u6837\u5F0F\u53D8\u91CF\u7684\u7C7B\u578B\u63D0\u793A\u3002</strong></p>\n<p>Vant \u63D0\u4F9B\u4E86 700 \u591A\u4E2A\u6837\u5F0F\u53D8\u91CF\uFF0C\u4F60\u53EF\u4EE5\u901A\u8FC7 CSS \u4EE3\u7801\u6216 <code>ConfigProvider</code> \u7EC4\u4EF6\u4FEE\u6539\u8FD9\u4E9B\u6837\u5F0F\u53D8\u91CF\u3002\u5728 Vant 4.0 \u4E2D\uFF0C\u6211\u4EEC\u65B0\u589E\u4E86 <code>ConfigProviderThemeVars</code> \u7C7B\u578B\uFF0C\u4EE5\u63D0\u4F9B\u6837\u5F0F\u53D8\u91CF\u7684\u7C7B\u578B\u63D0\u793A\u3002</p>\n<p>\u56E0\u6B64\u5728\u7F16\u5199 TypeScript \u4EE3\u7801\u65F6\uFF0C\u4F60\u53EF\u4EE5\u901A\u8FC7\u7C7B\u578B\u63D0\u793A\u6765\u8865\u5168\u4E3B\u9898\u53D8\u91CF\u540D\u79F0\uFF1A</p>\n<p><img src="https://user-images.githubusercontent.com/7237365/205478960-c284e272-a394-4098-ad0f-eda72e74f9f7.png" alt=""></p>\n</div><div class="van-doc-card"><h3 id="picker-zu-jian-chong-gou" tabindex="-1">Picker \u7EC4\u4EF6\u91CD\u6784</h3>\n<p><strong>Vant 4.0 \u91CD\u6784\u4E86 Picker \u7EC4\u4EF6\uFF0C\u4EE5\u53CA\u57FA\u4E8E Picker \u7684 Area \u548C DatetimePicker \u7EC4\u4EF6\u3002</strong></p>\n<p>\u5728\u4E4B\u524D\u7684\u7248\u672C\u4E2D\uFF0C<code>Picker</code> \u7EC4\u4EF6\u7684 API \u8BBE\u8BA1\u4E0D\u591F\u5408\u7406\uFF0C\u5BFC\u81F4\u5927\u5BB6\u5728\u4F7F\u7528\u65F6\u7ECF\u5E38\u9047\u5230\u95EE\u9898\uFF0C\u6BD4\u5982\uFF1A</p>\n<ul>\n<li>Picker \u7684 columns \u6570\u636E\u683C\u5F0F\u4E0D\u5408\u7406\uFF0C\u5BB9\u6613\u4EA7\u751F\u8BEF\u89E3\u3002</li>\n<li>Picker \u7684\u6570\u636E\u6D41\u4E0D\u6E05\u6670\uFF0C\u66B4\u9732\u4E86\u8FC7\u591A\u7684\u5B9E\u4F8B\u65B9\u6CD5\u6765\u5BF9\u6570\u636E\u8FDB\u884C\u64CD\u4F5C\u3002</li>\n<li>DatetimePicker \u7684\u903B\u8F91\u8FC7\u4E8E\u590D\u6742\uFF0C\u7ECF\u5E38\u5728\u8FB9\u754C\u573A\u666F\u4E0B\u51FA\u73B0 bug\u3002</li>\n</ul>\n<p>\u4E3A\u4E86\u89E3\u51B3\u4E0A\u8FF0\u95EE\u9898\uFF0C\u6211\u4EEC\u5728 Vant 4.0 \u4E2D\u5BF9 <code>Picker</code> \u7EC4\u4EF6\u8FDB\u884C\u4E86\u91CD\u6784\uFF0C\u540C\u65F6\u4E5F\u91CD\u6784\u4E86\u57FA\u4E8E <code>Picker</code> \u6D3E\u751F\u51FA\u7684 <code>Area</code> \u548C <code>DatetimePicker</code> \u7EC4\u4EF6\u3002</p>\n<p>\u5982\u679C\u4F60\u7684\u9879\u76EE\u4E2D\u4F7F\u7528\u4E86\u8FD9\u4E09\u4E2A\u7EC4\u4EF6\uFF0C\u8BF7\u9605\u8BFB <a href="https://vant-ui.github.io/vant/#/zh-CN/migrate-from-v3" target="_blank">\u300C\u5347\u7EA7\u6307\u5357\u300D</a> \u8FDB\u884C\u5347\u7EA7\u3002</p>\n</div><div class="van-doc-card"><h3 id="zu-jian-gong-ju-han-shu-diao-zheng" tabindex="-1">\u7EC4\u4EF6\u5DE5\u5177\u51FD\u6570\u8C03\u6574</h3>\n<p><strong>Vant 4.0 \u8C03\u6574\u4E86\u7EC4\u4EF6\u5DE5\u5177\u51FD\u6570\u7684\u7528\u6CD5\uFF0C\u4F7F\u5176\u66F4\u7B26\u5408\u76F4\u89C9\u3002</strong></p>\n<p>Vant 3 \u63D0\u4F9B\u4E86\u4E00\u4E9B\u7EC4\u4EF6\u5DE5\u5177\u51FD\u6570\uFF0C\u6BD4\u5982\u8C03\u7528 <code>Dialog()</code> \u51FD\u6570\uFF0C\u53EF\u4EE5\u5FEB\u901F\u5524\u8D77\u5168\u5C40\u7684\u5F39\u7A97\u7EC4\u4EF6\uFF0C\u800C <code>Dialog.Component</code> \u624D\u662F <code>Dialog</code> \u5BF9\u5E94\u7684\u7EC4\u4EF6\u5BF9\u8C61\u3002</p>\n<pre><code class="language-ts"><span class="hljs-comment">// \u51FD\u6570\u8C03\u7528</span>\n<span class="hljs-title class_">Dialog</span>({ <span class="hljs-attr">message</span>: <span class="hljs-string">'Hello World!'</span> });\n\n<span class="hljs-comment">// \u7EC4\u4EF6\u6CE8\u518C</span>\napp.<span class="hljs-title function_">use</span>(<span class="hljs-string">'van-dialog'</span>, <span class="hljs-title class_">Dialog</span>.<span class="hljs-property">Component</span>);\n</code></pre>\n<p>\u4EE5\u4E0A API \u8BBE\u8BA1\u5BFC\u81F4 Dialog \u7B49\u652F\u6301\u5DE5\u5177\u51FD\u6570\u7684\u7EC4\u4EF6\u4E0E\u5E38\u89C4\u7EC4\u4EF6\u5B58\u5728\u7528\u6CD5\u5DEE\u5F02\uFF0C\u5BB9\u6613\u88AB\u8BEF\u7528\uFF1B\u540C\u65F6\u4E5F\u5BFC\u81F4 <code>unplugin-vue-components</code> \u65E0\u6CD5\u81EA\u52A8\u5F15\u5165 Dialog \u7B49\u7EC4\u4EF6\u3002</p>\n<p>\u4E3A\u4E86\u66F4\u7B26\u5408\u76F4\u89C9\uFF0C\u6211\u4EEC\u5728 Vant 4 \u4E2D\u8C03\u6574\u4E86\u7EC4\u4EF6\u5DE5\u5177\u51FD\u6570\u7684\u8C03\u7528\u65B9\u5F0F\uFF0C\u53D7\u5F71\u54CD\u7684\u51FD\u6570\u5305\u62EC <code>Dialog()</code>\u3001<code>Toast()</code>\u3001<code>Notify()</code> \u548C <code>ImagePreview()</code>\u3002\u4EE5 Dialog \u4E3A\u4F8B\uFF0C\u6211\u4EEC\u5C06 <code>Dialog()</code> \u51FD\u6570\u91CD\u547D\u540D\u4E3A <code>showDialog()</code>\uFF0C\u5E76\u8BA9 <code>Dialog</code> \u76F4\u63A5\u6307\u5411\u7EC4\u4EF6\u5BF9\u8C61\u3002</p>\n<pre><code class="language-ts"><span class="hljs-comment">// \u51FD\u6570\u8C03\u7528</span>\n<span class="hljs-title function_">showDialog</span>({ <span class="hljs-attr">message</span>: <span class="hljs-string">'Hello World!'</span> });\n\n<span class="hljs-comment">// \u7EC4\u4EF6\u6CE8\u518C</span>\napp.<span class="hljs-title function_">use</span>(<span class="hljs-string">'van-dialog'</span>, <span class="hljs-title class_">Dialog</span>);\n</code></pre>\n<p>\u4E3A\u4E86\u4FBF\u4E8E\u5B58\u91CF\u4EE3\u7801\u8FC1\u79FB\u81F3 Vant 4.0\uFF0C\u6211\u4EEC\u63D0\u4F9B\u4E86\u517C\u5BB9\u65B9\u6848\uFF0C\u4F60\u53EF\u4EE5\u4F7F\u7528 <code>@vant/compat</code> \u4E2D\u5BFC\u51FA\u7684 <code>Dialog()</code> \u51FD\u6570\u6765\u517C\u5BB9\u539F\u6709\u4EE3\u7801\u3002</p>\n<pre><code class="language-js"><span class="hljs-keyword">import</span> { <span class="hljs-title class_">Dialog</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">'@vant/compat'</span>;\n\n<span class="hljs-title class_">Dialog</span>({ <span class="hljs-attr">message</span>: <span class="hljs-string">'Hello World!'</span> });\n</code></pre>\n<p><code>@vant/compat</code> \u4E2D\u5BFC\u51FA\u7684 <code>Dialog()</code> \u4E0E Vant 3 \u4E2D\u7684 <code>Dialog()</code> \u62E5\u6709\u5B8C\u5168\u4E00\u81F4\u7684 API \u548C\u884C\u4E3A\uFF0C\u56E0\u6B64\u5728\u5347\u7EA7\u65F6\uFF0C\u4F60\u53EA\u9700\u8981\u4FEE\u6539\u5B83\u7684\u5F15\u7528\u8DEF\u5F84\uFF0C\u5176\u4F59\u4EE3\u7801\u53EF\u4EE5\u4FDD\u6301\u4E0D\u53D8\u3002\u5728\u9879\u76EE\u5B8C\u6210\u5347\u7EA7\u5230 Vant 4.0 \u540E\uFF0C\u5EFA\u8BAE\u5728\u8FED\u4EE3\u4E2D\u9010\u6B65\u66FF\u6362\u4E3A\u65B0\u7684 <code>showDialog()</code> \u7B49\u65B9\u6CD5\uFF0C\u5E76\u79FB\u9664 <code>@vant/compat</code> \u5305\u3002</p>\n</div><div class="van-doc-card"><h3 id="shi-jian-ming-ming-diao-zheng" tabindex="-1">\u4E8B\u4EF6\u547D\u540D\u8C03\u6574</h3>\n<p><strong>Vant 4.0 \u5C06\u4E8B\u4EF6\u540D\u6539\u4E3A\u9A7C\u5CF0\u683C\u5F0F\u3002</strong></p>\n<p>\u4ECE Vant 4 \u5F00\u59CB\uFF0C\u6240\u6709\u7684\u4E8B\u4EF6\u5747\u91C7\u7528 Vue \u5B98\u65B9\u63A8\u8350\u7684\u9A7C\u5CF0\u683C\u5F0F\u8FDB\u884C\u547D\u540D\u3002</p>\n<pre><code class="language-js"><span class="hljs-comment">// Vant 3</span>\n<span class="hljs-title function_">emit</span>(<span class="hljs-string">'click-input'</span>);\n\n<span class="hljs-comment">// Vant 4</span>\n<span class="hljs-title function_">emit</span>(<span class="hljs-string">'clickInput'</span>);\n</code></pre>\n<p>\u8FD9\u9879\u6539\u52A8<strong>\u4E0D\u5F71\u54CD\u539F\u6709\u7684\u6A21\u677F\u4EE3\u7801</strong>\uFF0CVue \u4F1A\u81EA\u52A8\u5728\u6A21\u677F\u4E2D\u5BF9\u4E8B\u4EF6\u540D\u8FDB\u884C\u683C\u5F0F\u8F6C\u6362\uFF0C\u56E0\u6B64\u4F60\u65E0\u987B\u505A\u4EFB\u4F55\u66F4\u6539\u3002</p>\n<pre><code class="language-html"><span class="hljs-comment"><!-- \u4EE5\u4E0B\u4EE3\u7801\u53EF\u4EE5\u7167\u5E38\u8FD0\u884C\uFF0C\u65E0\u987B\u505A\u4EFB\u4F55\u66F4\u6539 --></span>\n<span class="hljs-tag"><<span class="hljs-name">van-field</span> @<span class="hljs-attr">click-input</span>=<span class="hljs-string">"onClick"</span> /></span>\n</code></pre>\n<p>\u5982\u679C\u4F60\u5728 JSX \u4E2D\u4F7F\u7528 Vant \u7EC4\u4EF6\uFF0C\u9700\u8981\u5C06\u76D1\u542C\u7684\u4E8B\u4EF6\u540D\u8C03\u6574\u4E3A\u9A7C\u5CF0\u683C\u5F0F\uFF0C\u539F\u6709\u7684\u4E2D\u5212\u7EBF\u683C\u5F0F\u5C06\u4E0D\u518D\u751F\u6548\uFF0C\u65B0\u7684\u76D1\u542C\u65B9\u5F0F\u66F4\u52A0\u7B26\u5408 JSX \u672C\u8EAB\u7684\u89C4\u8303\uFF1A</p>\n<pre><code class="language-jsx"><span class="hljs-comment">// Vant 3</span>\n<<span class="hljs-title class_">Field</span> onClick-input={onClick} />\n\n<span class="hljs-comment">// Vant 4</span>\n<span class="language-xml"><span class="hljs-tag"><<span class="hljs-name">Field</span> <span class="hljs-attr">onClickInput</span>=<span class="hljs-string">{onClick}</span> /></span></span>\n</code></pre>\n</div><div class="van-doc-card"><h3 id="yi-chu-less-bian-liang" tabindex="-1">\u79FB\u9664 Less \u53D8\u91CF</h3>\n<p><strong>Vant 4.0 \u4E0D\u518D\u652F\u6301\u901A\u8FC7 Less \u53D8\u91CF\u5B9A\u5236\u4E3B\u9898\u3002</strong></p>\n<p>\u76EE\u524D Vant \u5DF2\u7ECF\u652F\u6301\u57FA\u4E8E CSS \u53D8\u91CF\u7684\u4E3B\u9898\u5B9A\u5236\uFF0C\u76F8\u8F83\u4E8E Less \u5B9A\u5236\u66F4\u52A0\u7075\u6D3B\u3002\u56E0\u6B64\uFF0CVant 4 \u5C06\u4E0D\u518D\u63D0\u4F9B\u57FA\u4E8E Less \u7684\u4E3B\u9898\u5B9A\u5236\u3002\u8FD9\u610F\u5473\u7740 Vant \u7684 npm \u5305\u4E2D\u5C06\u4E0D\u518D\u4F1A\u5305\u542B <code>.less</code> \u6837\u5F0F\u6E90\u6587\u4EF6\uFF0C\u4EC5\u4F1A\u63D0\u4F9B\u7F16\u8BD1\u540E\u7684 <code>.css</code> \u6837\u5F0F\u6587\u4EF6\u3002</p>\n<p>\u5982\u679C\u4F60\u7684\u9879\u76EE\u6B63\u5728\u4F7F\u7528\u65E7\u7248\u7684 Less \u4E3B\u9898\u5B9A\u5236\uFF0C\u8BF7\u4F7F\u7528 <a href="#/zh-CN/config-provider" target="_blank">ConfigProvider \u5168\u5C40\u914D\u7F6E</a> \u8FDB\u884C\u66FF\u6362\u3002</p>\n</div><div class="van-doc-card"><h3 id="vant-cli-5.0" tabindex="-1">Vant Cli 5.0</h3>\n<p><strong>\u672C\u6B21\u66F4\u65B0\u540C\u6B65\u53D1\u5E03\u4E86 Vant Cli 5.0 \u7248\u672C\u3002</strong></p>\n<p><a href="https://github.com/youzan/vant/tree/main/packages/vant-cli" target="_blank">Vant Cli</a> \u662F Vant \u5E95\u5C42\u7684\u7EC4\u4EF6\u5E93\u6784\u5EFA\u5DE5\u5177\uFF0C\u672C\u6B21\u66F4\u65B0\u5185\u5BB9\u6709\uFF1A</p>\n<ul>\n<li>\u5347\u7EA7 Vite \u5230 3.0 \u7248\u672C\uFF0C\u5E76\u5BF9\u76F8\u5173\u7684 Vite \u63D2\u4EF6\u8FDB\u884C\u5347\u7EA7\u3002</li>\n<li>\u4E0D\u518D\u9ED8\u8BA4\u5B89\u88C5 <code>stylelint</code> \u548C <code>@vant/stylelint-config</code> \u4F9D\u8D56\uFF0C\u9700\u8981\u7684\u8BDD\u53EF\u4EE5\u81EA\u884C\u5B89\u88C5\uFF1A</li>\n</ul>\n<pre><code class="language-bash">npm add stylelint@13 @vant/stylelint-config\n</code></pre>\n<ul>\n<li>\u4E0D\u518D\u9ED8\u8BA4\u5B89\u88C5 <code>gh-pages</code> \u4F9D\u8D56\uFF0C\u8BF7\u6309\u7167\u5982\u4E0B\u65B9\u5F0F\u66F4\u65B0 package.json\uFF1A</li>\n</ul>\n<pre><code class="language-diff"><span class="hljs-deletion">- "release:site": "pnpm build:site && gh-pages -d site-dist",</span>\n<span class="hljs-addition">+ "release:site": "pnpm build:site && npx gh-pages -d site-dist",</span>\n</code></pre>\n</div><div class="van-doc-card"><h3 id="ban-ben-xin-xi" tabindex="-1">\u7248\u672C\u4FE1\u606F</h3>\n<p><strong>\u76EE\u524D <a href="https://vant-ui.github.io/vant/" target="_blank">Vant \u5B98\u7F51</a> \u548C npm latest \u6807\u7B7E\u5747\u5DF2\u6307\u5411 Vant 4.0\u3002</strong></p>\n<p>\u6211\u4EEC\u4E3A Vant 4.0 \u51C6\u5907\u4E86\u5B8C\u6574\u7684\u5347\u7EA7\u6307\u5357\uFF0C\u8BF7\u9605\u8BFB <a href="https://vant-ui.github.io/vant/#/zh-CN/migrate-from-v3" target="_blank">\u4ECE v3 \u5347\u7EA7\u5230 v4</a> \u8FDB\u884C\u5347\u7EA7\u3002</p>\n<p>\u540C\u65F6\uFF0CVant 3.x \u4E5F\u4F1A\u8FDB\u5165\u7EF4\u62A4\u72B6\u6001\uFF0C\u540E\u7EED Vant \u5404\u4E2A\u7248\u672C\u7684\u7EF4\u62A4\u72B6\u6001\u5982\u4E0B\uFF1A</p>\n<table>\n<thead>\n<tr>\n<th>\u540D\u79F0</th>\n<th>\u6846\u67B6</th>\n<th>\u53D1\u5E03\u65F6\u95F4</th>\n<th>\u7EF4\u62A4\u72B6\u6001</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Vant 4</td>\n<td>Vue 3</td>\n<td><code>2022.12</code></td>\n<td>\u6301\u7EED\u8FED\u4EE3\u65B0\u529F\u80FD</td>\n</tr>\n<tr>\n<td>Vant 3</td>\n<td>Vue 3</td>\n<td><code>2020.12</code></td>\n<td>\u505C\u6B62\u8FED\u4EE3\u65B0\u529F\u80FD\uFF0Cbug \u4F1A\u88AB\u5904\u7406\u548C\u4FEE\u590D</td>\n</tr>\n<tr>\n<td>Vant 2</td>\n<td>Vue 2</td>\n<td><code>2019.06</code></td>\n<td>\u505C\u6B62\u8FED\u4EE3\u65B0\u529F\u80FD\uFF0C\u91CD\u8981 bug \u4F1A\u88AB\u5904\u7406\u548C\u4FEE\u590D</td>\n</tr>\n<tr>\n<td>Vant 1</td>\n<td>Vue 2</td>\n<td><code>2018.03</code></td>\n<td>\u505C\u6B62\u7EF4\u62A4\uFF0C\u4E0D\u518D\u63A5\u53D7 PR</td>\n</tr>\n</tbody>\n</table>\n</div><div class="van-doc-card"><h3 id="zui-hou" tabindex="-1">\u6700\u540E</h3>\n<p>\u611F\u8C22\u5728 Vant 4.0 \u8FED\u4EE3\u671F\u95F4\u505A\u51FA\u8D21\u732E\u7684\u670B\u53CB\u4EEC\uFF0C\u611F\u8C22\u6240\u6709\u4F7F\u7528 Vant \u7684\u5F00\u53D1\u8005\uFF0C\u613F\u5927\u5BB6\u5728\u5F00\u6E90\u7684\u9053\u8DEF\u4E0A\u6B65\u5C65\u4E0D\u505C\u3002</p>\n<p><img src="https://user-images.githubusercontent.com/7237365/205481230-fdd89482-86ad-40c8-b81f-4af0789f8488.png" alt=""></p>\n</div>'},null,8,e))}}}]); |