mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
79 lines
19 KiB
JavaScript
79 lines
19 KiB
JavaScript
import{o as t,a,y as l}from"./vue-libs.b44bc779.js";const n={class:"van-doc-markdown-body"},e=l(`<h1>Cell</h1><div class="van-doc-card"><h3 id="intro" tabindex="-1">Intro</h3><p>The cell is a single display item in the list.</p></div><div class="van-doc-card"><h3 id="install" tabindex="-1">Install</h3><p>Register component globally via <code>app.use</code>, refer to <a href="#/en-US/advanced-usage#zu-jian-zhu-ce" target="_blank">Component Registration</a> for more registration ways.</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_">Cell</span>, <span class="hljs-title class_">CellGroup</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_">Cell</span>);
|
|
app.<span class="hljs-title function_">use</span>(<span class="hljs-title class_">CellGroup</span>);
|
|
</code></pre></div><h2 id="usage" tabindex="-1">Usage</h2><div class="van-doc-card"><h3 id="basic-usage" tabindex="-1">Basic Usage</h3><pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-cell-group</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-cell</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"Cell title"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"Content"</span> /></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-cell</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"Cell title"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"Content"</span> <span class="hljs-attr">label</span>=<span class="hljs-string">"Description"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-name">van-cell-group</span>></span>
|
|
</code></pre></div><div class="van-doc-card"><h3 id="inset-grouped" tabindex="-1">Inset Grouped</h3><pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-cell-group</span> <span class="hljs-attr">inset</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-cell</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"Cell title"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"Content"</span> /></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-cell</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"Cell title"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"Content"</span> <span class="hljs-attr">label</span>=<span class="hljs-string">"Description"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-name">van-cell-group</span>></span>
|
|
</code></pre></div><div class="van-doc-card"><h3 id="size" tabindex="-1">Size</h3><pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-cell-group</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-cell</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"Cell title"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"Content"</span> <span class="hljs-attr">size</span>=<span class="hljs-string">"large"</span> /></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-cell</span>
|
|
<span class="hljs-attr">title</span>=<span class="hljs-string">"Cell title"</span>
|
|
<span class="hljs-attr">value</span>=<span class="hljs-string">"Content"</span>
|
|
<span class="hljs-attr">size</span>=<span class="hljs-string">"large"</span>
|
|
<span class="hljs-attr">label</span>=<span class="hljs-string">"Description"</span>
|
|
/></span>
|
|
<span class="hljs-tag"></<span class="hljs-name">van-cell-group</span>></span>
|
|
</code></pre></div><div class="van-doc-card"><h3 id="left-icon" tabindex="-1">Left Icon</h3><pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-cell-group</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-cell</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"Cell title"</span> <span class="hljs-attr">icon</span>=<span class="hljs-string">"location-o"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-name">van-cell-group</span>></span>
|
|
</code></pre></div><div class="van-doc-card"><h3 id="value-only" tabindex="-1">Value only</h3><pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-cell-group</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-cell</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"Content"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-name">van-cell-group</span>></span>
|
|
</code></pre></div><div class="van-doc-card"><h3 id="link" tabindex="-1">Link</h3><pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-cell-group</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-cell</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"Cell title"</span> <span class="hljs-attr">is-link</span> /></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-cell</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"Cell title"</span> <span class="hljs-attr">is-link</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"Content"</span> /></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-cell</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"Cell title"</span> <span class="hljs-attr">is-link</span> <span class="hljs-attr">arrow-direction</span>=<span class="hljs-string">"down"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"Content"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-name">van-cell-group</span>></span>
|
|
</code></pre></div><div class="van-doc-card"><h3 id="router" tabindex="-1">Router</h3><pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-cell-group</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-cell</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"URL"</span> <span class="hljs-attr">is-link</span> <span class="hljs-attr">url</span>=<span class="hljs-string">"https://github.com"</span> /></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-cell</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"Vue Router"</span> <span class="hljs-attr">is-link</span> <span class="hljs-attr">to</span>=<span class="hljs-string">"index"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-name">van-cell-group</span>></span>
|
|
</code></pre></div><div class="van-doc-card"><h3 id="group-title" tabindex="-1">Group Title</h3><pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-cell-group</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"Group 1"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-cell</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"Cell title"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"Content"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-name">van-cell-group</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-cell-group</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"Group 2"</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-cell</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"Cell title"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"Content"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-name">van-cell-group</span>></span>
|
|
</code></pre></div><div class="van-doc-card"><h3 id="use-slots" tabindex="-1">Use Slots</h3><pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-cell</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"Content"</span> <span class="hljs-attr">is-link</span>></span>
|
|
<span class="hljs-comment"><!-- Use the title slot to customize the title --></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">template</span> #<span class="hljs-attr">title</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">span</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"custom-title"</span>></span>Title<span class="hljs-tag"></<span class="hljs-name">span</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-tag</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"danger"</span>></span>Tag<span class="hljs-tag"></<span class="hljs-name">van-tag</span>></span>
|
|
<span class="hljs-tag"></<span class="hljs-name">template</span>></span>
|
|
<span class="hljs-tag"></<span class="hljs-name">van-cell</span>></span>
|
|
|
|
<span class="hljs-tag"><<span class="hljs-name">van-cell</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"Title"</span> <span class="hljs-attr">icon</span>=<span class="hljs-string">"shop-o"</span>></span>
|
|
<span class="hljs-comment"><!-- Use the right-icon slot to customize the right icon --></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">template</span> #<span class="hljs-attr">right-icon</span>></span>
|
|
<span class="hljs-tag"><<span class="hljs-name">van-icon</span> <span class="hljs-attr">name</span>=<span class="hljs-string">"search"</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"search-icon"</span> /></span>
|
|
<span class="hljs-tag"></<span class="hljs-name">template</span>></span>
|
|
<span class="hljs-tag"></<span class="hljs-name">van-cell</span>></span>
|
|
|
|
<span class="hljs-tag"><<span class="hljs-name">style</span>></span><span class="language-css">
|
|
<span class="hljs-selector-class">.custom-title</span> {
|
|
<span class="hljs-attribute">margin-right</span>: <span class="hljs-number">4px</span>;
|
|
<span class="hljs-attribute">vertical-align</span>: middle;
|
|
}
|
|
|
|
<span class="hljs-selector-class">.search-icon</span> {
|
|
<span class="hljs-attribute">font-size</span>: <span class="hljs-number">16px</span>;
|
|
<span class="hljs-attribute">line-height</span>: inherit;
|
|
}
|
|
</span><span class="hljs-tag"></<span class="hljs-name">style</span>></span>
|
|
</code></pre></div><div class="van-doc-card"><h3 id="vertical-center" tabindex="-1">Vertical Center</h3><pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-cell</span> <span class="hljs-attr">center</span> <span class="hljs-attr">title</span>=<span class="hljs-string">"Cell title"</span> <span class="hljs-attr">value</span>=<span class="hljs-string">"Content"</span> <span class="hljs-attr">label</span>=<span class="hljs-string">"Description"</span> /></span>
|
|
</code></pre></div><h2 id="api" tabindex="-1">API</h2><div class="van-doc-card"><h3 id="cellgroup-props" tabindex="-1">CellGroup Props</h3><table><thead><tr><th>Attribute</th><th>Description</th><th>Type</th><th>Default</th></tr></thead><tbody><tr><td>title</td><td>Group title</td><td><em>string</em></td><td>-</td></tr><tr><td>inset <code>v3.1.0</code></td><td>Whether to be inset grouped</td><td><em>boolean</em></td><td><code>false</code></td></tr><tr><td>border</td><td>Whether to show outer border</td><td><em>boolean</em></td><td><code>true</code></td></tr></tbody></table></div><div class="van-doc-card"><h3 id="cell-props" tabindex="-1">Cell Props</h3><table><thead><tr><th>Attribute</th><th>Description</th><th>Type</th><th>Default</th></tr></thead><tbody><tr><td>title</td><td>Title</td><td><em>number | string</em></td><td>-</td></tr><tr><td>value</td><td>Right text</td><td><em>number | string</em></td><td>-</td></tr><tr><td>label</td><td>Description below the title</td><td><em>string</em></td><td>-</td></tr><tr><td>size</td><td>Size, can be set to <code>large</code></td><td><em>string</em></td><td>-</td></tr><tr><td>icon</td><td>Left Icon</td><td><em>string</em></td><td>-</td></tr><tr><td>icon-prefix</td><td>Icon className prefix</td><td><em>string</em></td><td><code>van-icon</code></td></tr><tr><td>border</td><td>Whether to show inner border</td><td><em>boolean</em></td><td><code>true</code></td></tr><tr><td>center</td><td>Whether to center content vertically</td><td><em>boolean</em></td><td><code>false</code></td></tr><tr><td>url</td><td>Link URL</td><td><em>string</em></td><td>-</td></tr><tr><td>to</td><td>Target route of the link, same as to of vue-router</td><td><em>string | object</em></td><td>-</td></tr><tr><td>replace</td><td>If true, the navigation will not leave a history record</td><td><em>boolean</em></td><td><code>false</code></td></tr><tr><td>clickable</td><td>Whether to show click feedback when clicked</td><td><em>boolean</em></td><td><code>null</code></td></tr><tr><td>is-link</td><td>Whether to show link icon</td><td><em>boolean</em></td><td><code>false</code></td></tr><tr><td>required</td><td>Whether to show required mark</td><td><em>boolean</em></td><td><code>false</code></td></tr><tr><td>arrow-direction</td><td>Can be set to <code>left</code> <code>up</code> <code>down</code></td><td><em>string</em></td><td><code>right</code></td></tr><tr><td>title-style</td><td>Title style</td><td><em>string | Array | object</em></td><td>-</td></tr><tr><td>title-class</td><td>Title className</td><td><em>string | Array | object</em></td><td>-</td></tr><tr><td>value-class</td><td>Value className</td><td><em>string | Array | object</em></td><td>-</td></tr><tr><td>label-class</td><td>Label className</td><td><em>string | Array | object</em></td><td>-</td></tr></tbody></table></div><div class="van-doc-card"><h3 id="cell-events" tabindex="-1">Cell Events</h3><table><thead><tr><th>Event</th><th>Description</th><th>Arguments</th></tr></thead><tbody><tr><td>click</td><td>Emitted when cell is clicked</td><td><em>event: MouseEvent</em></td></tr></tbody></table></div><div class="van-doc-card"><h3 id="cellgroup-slots" tabindex="-1">CellGroup Slots</h3><table><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td>default</td><td>Default slot</td></tr><tr><td>title</td><td>Custom title</td></tr></tbody></table></div><div class="van-doc-card"><h3 id="cell-slots" tabindex="-1">Cell Slots</h3><table><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td>title</td><td>Custom title</td></tr><tr><td>value <code>v3.1.1</code></td><td>Custom value</td></tr><tr><td>label</td><td>Custom label</td></tr><tr><td>icon</td><td>Custom left icon</td></tr><tr><td>right-icon</td><td>Custom right icon</td></tr><tr><td>extra</td><td>Custom extra content on the right</td></tr></tbody></table></div><div class="van-doc-card"><h3 id="types" tabindex="-1">Types</h3><p>The component exports the following type definitions:</p><pre><code class="language-ts"><span class="hljs-keyword">import</span> <span class="hljs-keyword">type</span> {
|
|
<span class="hljs-title class_">CellSize</span>,
|
|
<span class="hljs-title class_">CellProps</span>,
|
|
<span class="hljs-title class_">CellGroupProps</span>,
|
|
<span class="hljs-title class_">CellArrowDirection</span>,
|
|
} <span class="hljs-keyword">from</span> <span class="hljs-string">'vant'</span>;
|
|
</code></pre></div><h2 id="theming" tabindex="-1">Theming</h2><div class="van-doc-card"><h3 id="css-variables" tabindex="-1">CSS Variables</h3><p>The component provides the following CSS variables, which can be used to customize styles. Please refer to <a href="#/en-US/config-provider" target="_blank">ConfigProvider component</a>.</p><table><thead><tr><th>Name</th><th>Default Value</th><th>Description</th></tr></thead><tbody><tr><td>--van-cell-font-size</td><td><em>var(--van-font-size-md)</em></td><td>-</td></tr><tr><td>--van-cell-line-height</td><td><em>24px</em></td><td>-</td></tr><tr><td>--van-cell-vertical-padding</td><td><em>10px</em></td><td>-</td></tr><tr><td>--van-cell-horizontal-padding</td><td><em>var(--van-padding-md)</em></td><td>-</td></tr><tr><td>--van-cell-text-color</td><td><em>var(--van-text-color)</em></td><td>-</td></tr><tr><td>--van-cell-background-color</td><td><em>var(--van-background-color-light)</em></td><td>-</td></tr><tr><td>--van-cell-border-color</td><td><em>var(--van-border-color)</em></td><td>-</td></tr><tr><td>--van-cell-active-color</td><td><em>var(--van-active-color)</em></td><td>-</td></tr><tr><td>--van-cell-required-color</td><td><em>var(--van-danger-color)</em></td><td>-</td></tr><tr><td>--van-cell-label-color</td><td><em>var(--van-text-color-2)</em></td><td>-</td></tr><tr><td>--van-cell-label-font-size</td><td><em>var(--van-font-size-sm)</em></td><td>-</td></tr><tr><td>--van-cell-label-line-height</td><td><em>var(--van-line-height-sm)</em></td><td>-</td></tr><tr><td>--van-cell-label-margin-top</td><td><em>var(--van-padding-base)</em></td><td>-</td></tr><tr><td>--van-cell-value-color</td><td><em>var(--van-text-color-2)</em></td><td>-</td></tr><tr><td>--van-cell-icon-size</td><td><em>16px</em></td><td>-</td></tr><tr><td>--van-cell-right-icon-color</td><td><em>var(--van-gray-6)</em></td><td>-</td></tr><tr><td>--van-cell-large-vertical-padding</td><td><em>var(--van-padding-sm)</em></td><td>-</td></tr><tr><td>--van-cell-large-title-font-size</td><td><em>var(--van-font-size-lg)</em></td><td>-</td></tr><tr><td>--van-cell-large-label-font-size</td><td><em>var(--van-font-size-md)</em></td><td>-</td></tr><tr><td>--van-cell-group-background-color</td><td><em>var(--van-background-color-light)</em></td><td>-</td></tr><tr><td>--van-cell-group-title-color</td><td><em>var(--van-text-color-2)</em></td><td>-</td></tr><tr><td>--van-cell-group-title-padding</td><td><em>var(--van-padding-md) var(--van-padding-md) var(--van-padding-xs)</em></td><td>-</td></tr><tr><td>--van-cell-group-title-font-size</td><td><em>var(--van-font-size-md)</em></td><td>-</td></tr><tr><td>--van-cell-group-title-line-height</td><td><em>16px</em></td><td>-</td></tr><tr><td>--van-cell-group-inset-padding</td><td><em>0 var(--van-padding-md)</em></td><td>-</td></tr><tr><td>--van-cell-group-inset-border-radius</td><td><em>var(--van-border-radius-lg)</em></td><td>-</td></tr><tr><td>--van-cell-group-inset-title-padding</td><td><em>var(--van-padding-md) var(--van-padding-md) var(--van-padding-xs) var(--van-padding-xl)</em></td><td>-</td></tr></tbody></table></div>`,23),d=[e],h={__name:"README",setup(p,{expose:s}){return s({frontmatter:{}}),(r,o)=>(t(),a("div",n,d))}};export{h as default};
|