mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
63 lines
15 KiB
JavaScript
63 lines
15 KiB
JavaScript
import{o as s,a,y as n}from"./vue-libs.b44bc779.js";const d={class:"van-doc-markdown-body"},e=n(`<h1>Popup \u5F39\u51FA\u5C42</h1><div class="van-doc-card"><h3 id="jie-shao" tabindex="-1">\u4ECB\u7ECD</h3><p>\u5F39\u51FA\u5C42\u5BB9\u5668\uFF0C\u7528\u4E8E\u5C55\u793A\u5F39\u7A97\u3001\u4FE1\u606F\u63D0\u793A\u7B49\u5185\u5BB9\uFF0C\u652F\u6301\u591A\u4E2A\u5F39\u51FA\u5C42\u53E0\u52A0\u5C55\u793A\u3002</p></div><div class="van-doc-card"><h3 id="yin-ru" tabindex="-1">\u5F15\u5165</h3><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><pre><code class="language-js"><span class="hljs-keyword">import</span> { createApp } <span class="hljs-keyword">from</span> <span class="hljs-string">'vue'</span>;
|
|
<span class="hljs-keyword">import</span> { <span class="hljs-title class_">Popup</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">'vant'</span>;
|
|
|
|
<span class="hljs-keyword">const</span> app = <span class="hljs-title function_">createApp</span>();
|
|
app.<span class="hljs-title function_">use</span>(<span class="hljs-title class_">Popup</span>);
|
|
</code></pre></div><h2 id="dai-ma-yan-shi" tabindex="-1">\u4EE3\u7801\u6F14\u793A</h2><div class="van-doc-card"><h3 id="ji-chu-yong-fa" tabindex="-1">\u57FA\u7840\u7528\u6CD5</h3><p>\u901A\u8FC7 <code>v-model:show</code> \u63A7\u5236\u5F39\u51FA\u5C42\u662F\u5426\u5C55\u793A\u3002</p><pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-cell</span> <span class="hljs-attr">is-link</span> @<span class="hljs-attr">click</span>=<span class="hljs-string">"showPopup"</span>></span>\u5C55\u793A\u5F39\u51FA\u5C42<span class="hljs-tag"></<span class="hljs-name">van-cell</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-popup</span> <span class="hljs-attr">v-model:show</span>=<span class="hljs-string">"show"</span>></span>\u5185\u5BB9<span class="hljs-tag"></<span class="hljs-name">van-popup</span>></span>
|
|
</code></pre><pre><code class="language-js"><span class="hljs-keyword">import</span> { ref } <span class="hljs-keyword">from</span> <span class="hljs-string">'vue'</span>;
|
|
|
|
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {
|
|
<span class="hljs-title function_">setup</span>(<span class="hljs-params"></span>) {
|
|
<span class="hljs-keyword">const</span> show = <span class="hljs-title function_">ref</span>(<span class="hljs-literal">false</span>);
|
|
<span class="hljs-keyword">const</span> <span class="hljs-title function_">showPopup</span> = (<span class="hljs-params"></span>) => {
|
|
show.<span class="hljs-property">value</span> = <span class="hljs-literal">true</span>;
|
|
};
|
|
<span class="hljs-keyword">return</span> {
|
|
show,
|
|
showPopup,
|
|
};
|
|
},
|
|
};
|
|
</code></pre></div><div class="van-doc-card"><h3 id="dan-chu-wei-zhi" tabindex="-1">\u5F39\u51FA\u4F4D\u7F6E</h3><p>\u901A\u8FC7 <code>position</code> \u5C5E\u6027\u8BBE\u7F6E\u5F39\u51FA\u4F4D\u7F6E\uFF0C\u9ED8\u8BA4\u5C45\u4E2D\u5F39\u51FA\uFF0C\u53EF\u4EE5\u8BBE\u7F6E\u4E3A <code>top</code>\u3001<code>bottom</code>\u3001<code>left</code>\u3001<code>right</code>\u3002</p><pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-popup</span> <span class="hljs-attr">v-model:show</span>=<span class="hljs-string">"show"</span> <span class="hljs-attr">position</span>=<span class="hljs-string">"top"</span> <span class="hljs-attr">:style</span>=<span class="hljs-string">"{ height: '30%' }"</span> /></span>
|
|
</code></pre></div><div class="van-doc-card"><h3 id="guan-bi-tu-biao" tabindex="-1">\u5173\u95ED\u56FE\u6807</h3><p>\u8BBE\u7F6E <code>closeable</code> \u5C5E\u6027\u540E\uFF0C\u4F1A\u5728\u5F39\u51FA\u5C42\u7684\u53F3\u4E0A\u89D2\u663E\u793A\u5173\u95ED\u56FE\u6807\uFF0C\u5E76\u4E14\u53EF\u4EE5\u901A\u8FC7 <code>close-icon</code> \u5C5E\u6027\u81EA\u5B9A\u4E49\u56FE\u6807\uFF0C\u4F7F\u7528 <code>close-icon-position</code> \u5C5E\u6027\u53EF\u4EE5\u81EA\u5B9A\u4E49\u56FE\u6807\u4F4D\u7F6E\u3002</p><pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-popup</span>
|
|
<span class="hljs-attr">v-model:show</span>=<span class="hljs-string">"show"</span>
|
|
<span class="hljs-attr">closeable</span>
|
|
<span class="hljs-attr">position</span>=<span class="hljs-string">"bottom"</span>
|
|
<span class="hljs-attr">:style</span>=<span class="hljs-string">"{ height: '30%' }"</span>
|
|
/></span>
|
|
<span class="hljs-comment"><!-- \u81EA\u5B9A\u4E49\u56FE\u6807 --></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-popup</span>
|
|
<span class="hljs-attr">v-model:show</span>=<span class="hljs-string">"show"</span>
|
|
<span class="hljs-attr">closeable</span>
|
|
<span class="hljs-attr">close-icon</span>=<span class="hljs-string">"close"</span>
|
|
<span class="hljs-attr">position</span>=<span class="hljs-string">"bottom"</span>
|
|
<span class="hljs-attr">:style</span>=<span class="hljs-string">"{ height: '30%' }"</span>
|
|
/></span>
|
|
<span class="hljs-comment"><!-- \u56FE\u6807\u4F4D\u7F6E --></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-popup</span>
|
|
<span class="hljs-attr">v-model:show</span>=<span class="hljs-string">"show"</span>
|
|
<span class="hljs-attr">closeable</span>
|
|
<span class="hljs-attr">close-icon-position</span>=<span class="hljs-string">"top-left"</span>
|
|
<span class="hljs-attr">position</span>=<span class="hljs-string">"bottom"</span>
|
|
<span class="hljs-attr">:style</span>=<span class="hljs-string">"{ height: '30%' }"</span>
|
|
/></span>
|
|
</code></pre></div><div class="van-doc-card"><h3 id="yuan-jiao-dan-chuang" tabindex="-1">\u5706\u89D2\u5F39\u7A97</h3><p>\u8BBE\u7F6E <code>round</code> \u5C5E\u6027\u540E\uFF0C\u5F39\u7A97\u4F1A\u6839\u636E\u5F39\u51FA\u4F4D\u7F6E\u6DFB\u52A0\u4E0D\u540C\u7684\u5706\u89D2\u6837\u5F0F\u3002</p><pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-popup</span>
|
|
<span class="hljs-attr">v-model:show</span>=<span class="hljs-string">"show"</span>
|
|
<span class="hljs-attr">round</span>
|
|
<span class="hljs-attr">position</span>=<span class="hljs-string">"bottom"</span>
|
|
<span class="hljs-attr">:style</span>=<span class="hljs-string">"{ height: '30%' }"</span>
|
|
/></span>
|
|
</code></pre></div><div class="van-doc-card"><h3 id="zhi-ding-gua-zai-wei-zhi" tabindex="-1">\u6307\u5B9A\u6302\u8F7D\u4F4D\u7F6E</h3><p>\u5F39\u51FA\u5C42\u9ED8\u8BA4\u6302\u8F7D\u5230\u7EC4\u4EF6\u6807\u7B7E\u6240\u5728\u4F4D\u7F6E\uFF0C\u53EF\u4EE5\u901A\u8FC7 <code>teleport</code> \u5C5E\u6027\u6307\u5B9A\u6302\u8F7D\u4F4D\u7F6E\u3002</p><pre><code class="language-html"><span class="hljs-comment"><!-- \u6302\u8F7D\u5230 body \u8282\u70B9\u4E0B --></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-popup</span> <span class="hljs-attr">v-model:show</span>=<span class="hljs-string">"show"</span> <span class="hljs-attr">teleport</span>=<span class="hljs-string">"body"</span> /></span>
|
|
|
|
<span class="hljs-comment"><!-- \u6302\u8F7D\u5230 #app \u8282\u70B9\u4E0B --></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-popup</span> <span class="hljs-attr">v-model:show</span>=<span class="hljs-string">"show"</span> <span class="hljs-attr">teleport</span>=<span class="hljs-string">"#app"</span> /></span>
|
|
</code></pre></div><h2 id="api" tabindex="-1">API</h2><div class="van-doc-card"><h3 id="props" tabindex="-1">Props</h3><table><thead><tr><th>\u53C2\u6570</th><th>\u8BF4\u660E</th><th>\u7C7B\u578B</th><th>\u9ED8\u8BA4\u503C</th></tr></thead><tbody><tr><td>v-model:show</td><td>\u662F\u5426\u663E\u793A\u5F39\u51FA\u5C42</td><td><em>boolean</em></td><td><code>false</code></td></tr><tr><td>overlay</td><td>\u662F\u5426\u663E\u793A\u906E\u7F69\u5C42</td><td><em>boolean</em></td><td><code>true</code></td></tr><tr><td>position</td><td>\u5F39\u51FA\u4F4D\u7F6E\uFF0C\u53EF\u9009\u503C\u4E3A <code>top</code> <code>bottom</code> <code>right</code> <code>left</code></td><td><em>string</em></td><td><code>center</code></td></tr><tr><td>overlay-class</td><td>\u81EA\u5B9A\u4E49\u906E\u7F69\u5C42\u7C7B\u540D</td><td><em>string | Array | object</em></td><td>-</td></tr><tr><td>overlay-style</td><td>\u81EA\u5B9A\u4E49\u906E\u7F69\u5C42\u6837\u5F0F</td><td><em>object</em></td><td>-</td></tr><tr><td>duration</td><td>\u52A8\u753B\u65F6\u957F\uFF0C\u5355\u4F4D\u79D2\uFF0C\u8BBE\u7F6E\u4E3A 0 \u53EF\u4EE5\u7981\u7528\u52A8\u753B</td><td><em>number | string</em></td><td><code>0.3</code></td></tr><tr><td>round</td><td>\u662F\u5426\u663E\u793A\u5706\u89D2</td><td><em>boolean</em></td><td><code>false</code></td></tr><tr><td>lock-scroll</td><td>\u662F\u5426\u9501\u5B9A\u80CC\u666F\u6EDA\u52A8</td><td><em>boolean</em></td><td><code>true</code></td></tr><tr><td>lazy-render</td><td>\u662F\u5426\u5728\u663E\u793A\u5F39\u5C42\u65F6\u624D\u6E32\u67D3\u8282\u70B9</td><td><em>boolean</em></td><td><code>true</code></td></tr><tr><td>close-on-popstate</td><td>\u662F\u5426\u5728\u9875\u9762\u56DE\u9000\u65F6\u81EA\u52A8\u5173\u95ED</td><td><em>boolean</em></td><td><code>false</code></td></tr><tr><td>close-on-click-overlay</td><td>\u662F\u5426\u5728\u70B9\u51FB\u906E\u7F69\u5C42\u540E\u5173\u95ED</td><td><em>boolean</em></td><td><code>true</code></td></tr><tr><td>closeable</td><td>\u662F\u5426\u663E\u793A\u5173\u95ED\u56FE\u6807</td><td><em>boolean</em></td><td><code>false</code></td></tr><tr><td>close-icon</td><td>\u5173\u95ED\u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5\uFF0C\u7B49\u540C\u4E8E Icon \u7EC4\u4EF6\u7684 <a href="#/zh-CN/icon#props" target="_blank">name \u5C5E\u6027</a></td><td><em>string</em></td><td><code>cross</code></td></tr><tr><td>close-icon-position</td><td>\u5173\u95ED\u56FE\u6807\u4F4D\u7F6E\uFF0C\u53EF\u9009\u503C\u4E3A <code>top-left</code><br><code>bottom-left</code> <code>bottom-right</code></td><td><em>string</em></td><td><code>top-right</code></td></tr><tr><td>before-close <code>v3.1.4</code></td><td>\u5173\u95ED\u524D\u7684\u56DE\u8C03\u51FD\u6570\uFF0C\u8FD4\u56DE <code>false</code> \u53EF\u963B\u6B62\u5173\u95ED\uFF0C\u652F\u6301\u8FD4\u56DE Promise</td><td><em>(action: string) => boolean | Promise<boolean></em></td><td>-</td></tr><tr><td>icon-prefix <code>v3.0.18</code></td><td>\u56FE\u6807\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><td><em>string</em></td><td><code>van-icon</code></td></tr><tr><td>transition</td><td>\u52A8\u753B\u7C7B\u540D\uFF0C\u7B49\u4EF7\u4E8E <a href="https://v3.cn.vuejs.org/api/built-in-components.html#transition" target="_blank">transition</a> \u7684 <code>name</code> \u5C5E\u6027</td><td><em>string</em></td><td>-</td></tr><tr><td>transition-appear</td><td>\u662F\u5426\u5728\u521D\u59CB\u6E32\u67D3\u65F6\u542F\u7528\u8FC7\u6E21\u52A8\u753B</td><td><em>boolean</em></td><td><code>false</code></td></tr><tr><td>teleport</td><td>\u6307\u5B9A\u6302\u8F7D\u7684\u8282\u70B9\uFF0C\u7B49\u540C\u4E8E Teleport \u7EC4\u4EF6\u7684 <a href="https://v3.cn.vuejs.org/api/built-in-components.html#teleport" target="_blank">to \u5C5E\u6027</a></td><td><em>string | Element</em></td><td>-</td></tr><tr><td>safe-area-inset-top</td><td>\u662F\u5426\u5F00\u542F<a href="#/zh-CN/advanced-usage#di-bu-an-quan-qu-gua-pei" target="_blank">\u9876\u90E8\u5B89\u5168\u533A\u9002\u914D</a></td><td><em>boolean</em></td><td><code>false</code></td></tr><tr><td>safe-area-inset-bottom</td><td>\u662F\u5426\u5F00\u542F<a href="#/zh-CN/advanced-usage#di-bu-an-quan-qu-gua-pei" target="_blank">\u5E95\u90E8\u5B89\u5168\u533A\u9002\u914D</a></td><td><em>boolean</em></td><td><code>false</code></td></tr></tbody></table></div><div class="van-doc-card"><h3 id="events" tabindex="-1">Events</h3><table><thead><tr><th>\u4E8B\u4EF6\u540D</th><th>\u8BF4\u660E</th><th>\u56DE\u8C03\u53C2\u6570</th></tr></thead><tbody><tr><td>click</td><td>\u70B9\u51FB\u5F39\u51FA\u5C42\u65F6\u89E6\u53D1</td><td><em>event: MouseEvent</em></td></tr><tr><td>click-overlay</td><td>\u70B9\u51FB\u906E\u7F69\u5C42\u65F6\u89E6\u53D1</td><td><em>event: MouseEvent</em></td></tr><tr><td>click-close-icon</td><td>\u70B9\u51FB\u5173\u95ED\u56FE\u6807\u65F6\u89E6\u53D1</td><td><em>event: MouseEvent</em></td></tr><tr><td>open</td><td>\u6253\u5F00\u5F39\u51FA\u5C42\u65F6\u89E6\u53D1</td><td>-</td></tr><tr><td>close</td><td>\u5173\u95ED\u5F39\u51FA\u5C42\u65F6\u89E6\u53D1</td><td>-</td></tr><tr><td>opened</td><td>\u6253\u5F00\u5F39\u51FA\u5C42\u4E14\u52A8\u753B\u7ED3\u675F\u540E\u89E6\u53D1</td><td>-</td></tr><tr><td>closed</td><td>\u5173\u95ED\u5F39\u51FA\u5C42\u4E14\u52A8\u753B\u7ED3\u675F\u540E\u89E6\u53D1</td><td>-</td></tr></tbody></table></div><div class="van-doc-card"><h3 id="slots" tabindex="-1">Slots</h3><table><thead><tr><th>\u540D\u79F0</th><th>\u8BF4\u660E</th></tr></thead><tbody><tr><td>default</td><td>\u5F39\u7A97\u5185\u5BB9</td></tr><tr><td>overlay-content <code>v3.0.18</code></td><td>\u906E\u7F69\u5C42\u7684\u5185\u5BB9</td></tr></tbody></table></div><div class="van-doc-card"><h3 id="lei-xing-ding-yi" tabindex="-1">\u7C7B\u578B\u5B9A\u4E49</h3><p>\u7EC4\u4EF6\u5BFC\u51FA\u4EE5\u4E0B\u7C7B\u578B\u5B9A\u4E49\uFF1A</p><pre><code class="language-ts"><span class="hljs-keyword">import</span> <span class="hljs-keyword">type</span> {
|
|
<span class="hljs-title class_">PopupProps</span>,
|
|
<span class="hljs-title class_">PopupPosition</span>,
|
|
<span class="hljs-title class_">PopupInstance</span>,
|
|
<span class="hljs-title class_">PopupCloseIconPosition</span>,
|
|
} <span class="hljs-keyword">from</span> <span class="hljs-string">'vant'</span>;
|
|
</code></pre></div><h2 id="zhu-ti-ding-zhi" tabindex="-1">\u4E3B\u9898\u5B9A\u5236</h2><div class="van-doc-card"><h3 id="yang-shi-bian-liang" tabindex="-1">\u6837\u5F0F\u53D8\u91CF</h3><p>\u7EC4\u4EF6\u63D0\u4F9B\u4E86\u4E0B\u5217 CSS \u53D8\u91CF\uFF0C\u53EF\u7528\u4E8E\u81EA\u5B9A\u4E49\u6837\u5F0F\uFF0C\u4F7F\u7528\u65B9\u6CD5\u8BF7\u53C2\u8003 <a href="#/zh-CN/config-provider" target="_blank">ConfigProvider \u7EC4\u4EF6</a>\u3002</p><table><thead><tr><th>\u540D\u79F0</th><th>\u9ED8\u8BA4\u503C</th><th>\u63CF\u8FF0</th></tr></thead><tbody><tr><td>--van-popup-background-color</td><td><em>var(--van-background-color-light)</em></td><td>-</td></tr><tr><td>--van-popup-transition</td><td><em>transform var(--van-animation-duration-base)</em></td><td>-</td></tr><tr><td>--van-popup-round-border-radius</td><td><em>16px</em></td><td>-</td></tr><tr><td>--van-popup-close-icon-size</td><td><em>22px</em></td><td>-</td></tr><tr><td>--van-popup-close-icon-color</td><td><em>var(--van-gray-5)</em></td><td>-</td></tr><tr><td>--van-popup-close-icon-margin</td><td><em>16px</em></td><td>-</td></tr><tr><td>--van-popup-close-icon-z-index</td><td><em>1</em></td><td>-</td></tr></tbody></table></div>`,16),o=[e],i={__name:"README.zh-CN",setup(l,{expose:t}){return t({frontmatter:{}}),(c,r)=>(s(),a("div",d,o))}};export{i as default};
|