mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
2 lines
15 KiB
JavaScript
2 lines
15 KiB
JavaScript
/*! For license information please see 3358.55d1bd45.js.LICENSE.txt */
|
|
(self.webpackChunk=self.webpackChunk||[]).push([["3358"],{65688:function(s,n,t){"use strict";t.r(n);var a=t("80681");let l=["innerHTML"];n.default={setup:()=>({html:""}),render:()=>((0,a.wg)(),(0,a.iD)("div",{class:"van-doc-markdown-body",innerHTML:'<h1>Grid</h1>\n<div class="van-doc-card"><h3 id="intro" tabindex="-1">Intro</h3>\n<p>Used to divide the page into blocks of equal width in the horizontal direction for displaying content or page navigation.</p>\n</div><div class="van-doc-card"><h3 id="install" tabindex="-1">Install</h3>\n<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>\n<pre><code class="language-js"><span class="hljs-keyword">import</span> { createApp } <span class="hljs-keyword">from</span> <span class="hljs-string">'vue'</span>;\n<span class="hljs-keyword">import</span> { <span class="hljs-title class_">Grid</span>, <span class="hljs-title class_">GridItem</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">'vant'</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_">Grid</span>);\napp.<span class="hljs-title function_">use</span>(<span class="hljs-title class_">GridItem</span>);\n</code></pre>\n</div><h2 id="usage" tabindex="-1">Usage</h2>\n<div class="van-doc-card"><h3 id="basic-usage" tabindex="-1">Basic Usage</h3>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-grid</span>></span>\n <span class="hljs-tag"><<span class="hljs-name">van-grid-item</span> <span class="hljs-attr">icon</span>=<span class="hljs-string">"photo-o"</span> <span class="hljs-attr">text</span>=<span class="hljs-string">"Text"</span> /></span>\n <span class="hljs-tag"><<span class="hljs-name">van-grid-item</span> <span class="hljs-attr">icon</span>=<span class="hljs-string">"photo-o"</span> <span class="hljs-attr">text</span>=<span class="hljs-string">"Text"</span> /></span>\n <span class="hljs-tag"><<span class="hljs-name">van-grid-item</span> <span class="hljs-attr">icon</span>=<span class="hljs-string">"photo-o"</span> <span class="hljs-attr">text</span>=<span class="hljs-string">"Text"</span> /></span>\n <span class="hljs-tag"><<span class="hljs-name">van-grid-item</span> <span class="hljs-attr">icon</span>=<span class="hljs-string">"photo-o"</span> <span class="hljs-attr">text</span>=<span class="hljs-string">"Text"</span> /></span>\n<span class="hljs-tag"></<span class="hljs-name">van-grid</span>></span>\n</code></pre>\n</div><div class="van-doc-card"><h3 id="column-num" tabindex="-1">Column Num</h3>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-grid</span> <span class="hljs-attr">:column-num</span>=<span class="hljs-string">"3"</span>></span>\n <span class="hljs-tag"><<span class="hljs-name">van-grid-item</span> <span class="hljs-attr">v-for</span>=<span class="hljs-string">"value in 6"</span> <span class="hljs-attr">:key</span>=<span class="hljs-string">"value"</span> <span class="hljs-attr">icon</span>=<span class="hljs-string">"photo-o"</span> <span class="hljs-attr">text</span>=<span class="hljs-string">"Text"</span> /></span>\n<span class="hljs-tag"></<span class="hljs-name">van-grid</span>></span>\n</code></pre>\n</div><div class="van-doc-card"><h3 id="custom-content" tabindex="-1">Custom Content</h3>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-grid</span> <span class="hljs-attr">:border</span>=<span class="hljs-string">"false"</span> <span class="hljs-attr">:column-num</span>=<span class="hljs-string">"3"</span>></span>\n <span class="hljs-tag"><<span class="hljs-name">van-grid-item</span>></span>\n <span class="hljs-tag"><<span class="hljs-name">van-image</span>\n <span class="hljs-attr">src</span>=<span class="hljs-string">"https://fastly.jsdelivr.net/npm/@vant/assets/apple-1.jpeg"</span>\n /></span>\n <span class="hljs-tag"></<span class="hljs-name">van-grid-item</span>></span>\n <span class="hljs-tag"><<span class="hljs-name">van-grid-item</span>></span>\n <span class="hljs-tag"><<span class="hljs-name">van-image</span>\n <span class="hljs-attr">src</span>=<span class="hljs-string">"https://fastly.jsdelivr.net/npm/@vant/assets/apple-2.jpeg"</span>\n /></span>\n <span class="hljs-tag"></<span class="hljs-name">van-grid-item</span>></span>\n <span class="hljs-tag"><<span class="hljs-name">van-grid-item</span>></span>\n <span class="hljs-tag"><<span class="hljs-name">van-image</span>\n <span class="hljs-attr">src</span>=<span class="hljs-string">"https://fastly.jsdelivr.net/npm/@vant/assets/apple-3.jpeg"</span>\n /></span>\n <span class="hljs-tag"></<span class="hljs-name">van-grid-item</span>></span>\n<span class="hljs-tag"></<span class="hljs-name">van-grid</span>></span>\n</code></pre>\n</div><div class="van-doc-card"><h3 id="square" tabindex="-1">Square</h3>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-grid</span> <span class="hljs-attr">square</span>></span>\n <span class="hljs-tag"><<span class="hljs-name">van-grid-item</span> <span class="hljs-attr">v-for</span>=<span class="hljs-string">"value in 8"</span> <span class="hljs-attr">:key</span>=<span class="hljs-string">"value"</span> <span class="hljs-attr">icon</span>=<span class="hljs-string">"photo-o"</span> <span class="hljs-attr">text</span>=<span class="hljs-string">"Text"</span> /></span>\n<span class="hljs-tag"></<span class="hljs-name">van-grid</span>></span>\n</code></pre>\n</div><div class="van-doc-card"><h3 id="gutter" tabindex="-1">Gutter</h3>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-grid</span> <span class="hljs-attr">:gutter</span>=<span class="hljs-string">"10"</span>></span>\n <span class="hljs-tag"><<span class="hljs-name">van-grid-item</span> <span class="hljs-attr">v-for</span>=<span class="hljs-string">"value in 8"</span> <span class="hljs-attr">:key</span>=<span class="hljs-string">"value"</span> <span class="hljs-attr">icon</span>=<span class="hljs-string">"photo-o"</span> <span class="hljs-attr">text</span>=<span class="hljs-string">"Text"</span> /></span>\n<span class="hljs-tag"></<span class="hljs-name">van-grid</span>></span>\n</code></pre>\n</div><div class="van-doc-card"><h3 id="horizontal" tabindex="-1">Horizontal</h3>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-grid</span> <span class="hljs-attr">direction</span>=<span class="hljs-string">"horizontal"</span> <span class="hljs-attr">:column-num</span>=<span class="hljs-string">"3"</span>></span>\n <span class="hljs-tag"><<span class="hljs-name">van-grid-item</span> <span class="hljs-attr">icon</span>=<span class="hljs-string">"photo-o"</span> <span class="hljs-attr">text</span>=<span class="hljs-string">"\u6587\u5B57"</span> /></span>\n <span class="hljs-tag"><<span class="hljs-name">van-grid-item</span> <span class="hljs-attr">icon</span>=<span class="hljs-string">"photo-o"</span> <span class="hljs-attr">text</span>=<span class="hljs-string">"\u6587\u5B57"</span> /></span>\n <span class="hljs-tag"><<span class="hljs-name">van-grid-item</span> <span class="hljs-attr">icon</span>=<span class="hljs-string">"photo-o"</span> <span class="hljs-attr">text</span>=<span class="hljs-string">"\u6587\u5B57"</span> /></span>\n<span class="hljs-tag"></<span class="hljs-name">van-grid</span>></span>\n</code></pre>\n</div><div class="van-doc-card"><h3 id="route" tabindex="-1">Route</h3>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-grid</span> <span class="hljs-attr">clickable</span> <span class="hljs-attr">:column-num</span>=<span class="hljs-string">"2"</span>></span>\n <span class="hljs-tag"><<span class="hljs-name">van-grid-item</span> <span class="hljs-attr">icon</span>=<span class="hljs-string">"home-o"</span> <span class="hljs-attr">text</span>=<span class="hljs-string">"Vue Router"</span> <span class="hljs-attr">to</span>=<span class="hljs-string">"/"</span> /></span>\n <span class="hljs-tag"><<span class="hljs-name">van-grid-item</span> <span class="hljs-attr">icon</span>=<span class="hljs-string">"search"</span> <span class="hljs-attr">text</span>=<span class="hljs-string">"URL"</span> <span class="hljs-attr">url</span>=<span class="hljs-string">"https://github.com"</span> /></span>\n<span class="hljs-tag"></<span class="hljs-name">van-grid</span>></span>\n</code></pre>\n</div><div class="van-doc-card"><h3 id="show-badge" tabindex="-1">Show Badge</h3>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-grid</span> <span class="hljs-attr">:column-num</span>=<span class="hljs-string">"2"</span>></span>\n <span class="hljs-tag"><<span class="hljs-name">van-grid-item</span> <span class="hljs-attr">icon</span>=<span class="hljs-string">"home-o"</span> <span class="hljs-attr">text</span>=<span class="hljs-string">"Text"</span> <span class="hljs-attr">dot</span> /></span>\n <span class="hljs-tag"><<span class="hljs-name">van-grid-item</span> <span class="hljs-attr">icon</span>=<span class="hljs-string">"search"</span> <span class="hljs-attr">text</span>=<span class="hljs-string">"Text"</span> <span class="hljs-attr">badge</span>=<span class="hljs-string">"99+"</span> /></span>\n<span class="hljs-tag"></<span class="hljs-name">van-grid</span>></span>\n</code></pre>\n</div><h2 id="api" tabindex="-1">API</h2>\n<div class="van-doc-card"><h3 id="grid-props" tabindex="-1">Grid Props</h3>\n<table>\n<thead>\n<tr>\n<th>Attribute</th>\n<th>Description</th>\n<th>Type</th>\n<th>Default</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>column-num</td>\n<td>Column Num</td>\n<td><em>number | string</em></td>\n<td><code>4</code></td>\n</tr>\n<tr>\n<td>icon-size</td>\n<td>Icon size</td>\n<td><em>number | string</em></td>\n<td><code>28px</code></td>\n</tr>\n<tr>\n<td>gutter</td>\n<td>Gutter</td>\n<td><em>number | string</em></td>\n<td><code>0</code></td>\n</tr>\n<tr>\n<td>border</td>\n<td>Whether to show border</td>\n<td><em>boolean</em></td>\n<td><code>true</code></td>\n</tr>\n<tr>\n<td>center</td>\n<td>Whether to center content</td>\n<td><em>boolean</em></td>\n<td><code>true</code></td>\n</tr>\n<tr>\n<td>square</td>\n<td>Whether to be square shape</td>\n<td><em>boolean</em></td>\n<td><code>false</code></td>\n</tr>\n<tr>\n<td>clickable</td>\n<td>Whether to show click feedback when clicked</td>\n<td><em>boolean</em></td>\n<td><code>false</code></td>\n</tr>\n<tr>\n<td>direction</td>\n<td>Content arrangement direction, can be set to <code>horizontal</code></td>\n<td><em>string</em></td>\n<td><code>vertical</code></td>\n</tr>\n<tr>\n<td>reverse</td>\n<td>Whether to reverse the position of icon and text</td>\n<td><em>boolean</em></td>\n<td><code>false</code></td>\n</tr>\n</tbody>\n</table>\n</div><div class="van-doc-card"><h3 id="griditem-props" tabindex="-1">GridItem Props</h3>\n<table>\n<thead>\n<tr>\n<th>Attribute</th>\n<th>Description</th>\n<th>Type</th>\n<th>Default</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>text</td>\n<td>Text</td>\n<td><em>string</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>icon</td>\n<td>Icon name or URL</td>\n<td><em>string</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>icon-prefix</td>\n<td>Icon className prefix</td>\n<td><em>string</em></td>\n<td><code>van-icon</code></td>\n</tr>\n<tr>\n<td>icon-color</td>\n<td>Icon color</td>\n<td><em>string</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>dot</td>\n<td>Whether to show red dot</td>\n<td><em>boolean</em></td>\n<td><code>false</code></td>\n</tr>\n<tr>\n<td>badge</td>\n<td>Content of the badge</td>\n<td><em>number | string</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>badge-props</td>\n<td>Props of Badge, see <a href="#/en-US/badge#props" target="_blank">Badge - props</a></td>\n<td><em>BadgeProps</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>url</td>\n<td>Link URL</td>\n<td><em>string</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>to</td>\n<td>The target route should navigate to when clicked on, same as the <a href="https://router.vuejs.org/api/interfaces/RouterLinkProps.html#Properties-to" target="_blank">to prop</a> of Vue Router</td>\n<td><em>string | object</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>replace</td>\n<td>If true, the navigation will not leave a history record</td>\n<td><em>boolean</em></td>\n<td><code>false</code></td>\n</tr>\n</tbody>\n</table>\n</div><div class="van-doc-card"><h3 id="griditem-events" tabindex="-1">GridItem Events</h3>\n<table>\n<thead>\n<tr>\n<th>Event</th>\n<th>Description</th>\n<th>Arguments</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>click</td>\n<td>Emitted when component is clicked</td>\n<td><em>event: MouseEvent</em></td>\n</tr>\n</tbody>\n</table>\n</div><div class="van-doc-card"><h3 id="griditem-slots" tabindex="-1">GridItem Slots</h3>\n<table>\n<thead>\n<tr>\n<th>Name</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>default</td>\n<td>Custom content</td>\n</tr>\n<tr>\n<td>icon</td>\n<td>Custom icon</td>\n</tr>\n<tr>\n<td>text</td>\n<td>Custom text</td>\n</tr>\n</tbody>\n</table>\n</div><div class="van-doc-card"><h3 id="types" tabindex="-1">Types</h3>\n<p>The component exports the following type definitions:</p>\n<pre><code class="language-ts"><span class="hljs-keyword">import</span> <span class="hljs-keyword">type</span> { <span class="hljs-title class_">GridProps</span>, <span class="hljs-title class_">GridDirection</span>, <span class="hljs-title class_">GridItemProps</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">'vant'</span>;\n</code></pre>\n</div><h2 id="theming" tabindex="-1">Theming</h2>\n<div class="van-doc-card"><h3 id="css-variables" tabindex="-1">CSS Variables</h3>\n<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>\n<table>\n<thead>\n<tr>\n<th>Name</th>\n<th>Default Value</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>--van-grid-item-content-padding</td>\n<td><em>var(--van-padding-md) var(--van-padding-xs)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-grid-item-content-background</td>\n<td><em>var(--van-background-2)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-grid-item-content-active-color</td>\n<td><em>var(--van-active-color)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-grid-item-icon-size</td>\n<td><em>28px</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-grid-item-text-color</td>\n<td><em>var(--van-text-color)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-grid-item-text-font-size</td>\n<td><em>var(--van-font-size-sm)</em></td>\n<td>-</td>\n</tr>\n</tbody>\n</table>\n</div>'},null,8,l))}}}]); |