1
0
mirror of https://gitee.com/vant-contrib/vant.git synced 2025-04-24 02:16:12 +08:00
vant/static/js/async/3683.b85c1268.js
2024-04-20 08:49:23 +00:00

2 lines
14 KiB
JavaScript

/*! For license information please see 3683.b85c1268.js.LICENSE.txt */
(self.webpackChunk=self.webpackChunk||[]).push([["3683"],{94621:function(s,n,t){"use strict";t.r(n);var a=t("80681");let e=["innerHTML"];n.default={setup:()=>({html:""}),render:()=>((0,a.wg)(),(0,a.iD)("div",{class:"van-doc-markdown-body",innerHTML:'<h1>TextEllipsis</h1>\n<div class="van-doc-card"><h3 id="intro" tabindex="-1">Intro</h3>\n<p>Display ellipsis for long text and support for expanding or collapsing text. Please upgrade <code>vant</code> to &gt;= v4.1.0 before using this component.</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">&#x27;vue&#x27;</span>;\n<span class="hljs-keyword">import</span> { <span class="hljs-title class_">TextEllipsis</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;vant&#x27;</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_">TextEllipsis</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<p>Show one rows by default.</p>\n<pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">van-text-ellipsis</span> <span class="hljs-attr">:content</span>=<span class="hljs-string">&quot;text&quot;</span> /&gt;</span>\n</code></pre>\n<pre><code class="language-js"><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {\n <span class="hljs-title function_">setup</span>(<span class="hljs-params"></span>) {\n <span class="hljs-keyword">const</span> text =\n <span class="hljs-string">&#x27;Take your time and be patient. Life itself will eventually answer all those questions it once raised for you.&#x27;</span>;\n <span class="hljs-keyword">return</span> { text };\n },\n};\n</code></pre>\n</div><div class="van-doc-card"><h3 id="expand-collapse" tabindex="-1">Expand/Collapse</h3>\n<p>Support Expand/Collapse.</p>\n<pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">van-text-ellipsis</span>\n <span class="hljs-attr">:content</span>=<span class="hljs-string">&quot;text&quot;</span>\n <span class="hljs-attr">expand-text</span>=<span class="hljs-string">&quot;expand&quot;</span>\n <span class="hljs-attr">collapse-text</span>=<span class="hljs-string">&quot;collapse&quot;</span>\n/&gt;</span>\n</code></pre>\n<pre><code class="language-js"><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {\n <span class="hljs-title function_">setup</span>(<span class="hljs-params"></span>) {\n <span class="hljs-keyword">const</span> text =\n <span class="hljs-string">&quot;The fleeting time of one&#x27;s life is everything that belongs to a person. Only this thing truly belongs to you. Everything else is just a momentary pleasure or misfortune, which will soon be gone with the passing of time.&quot;</span>;\n <span class="hljs-keyword">return</span> { text };\n },\n};\n</code></pre>\n</div><div class="van-doc-card"><h3 id="customize-rows" tabindex="-1">Customize rows</h3>\n<p>Display the number of <code>rows</code> by setting rows.</p>\n<pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">van-text-ellipsis</span>\n <span class="hljs-attr">rows</span>=<span class="hljs-string">&quot;3&quot;</span>\n <span class="hljs-attr">:content</span>=<span class="hljs-string">&quot;text&quot;</span>\n <span class="hljs-attr">expand-text</span>=<span class="hljs-string">&quot;expand&quot;</span>\n <span class="hljs-attr">collapse-text</span>=<span class="hljs-string">&quot;collapse&quot;</span>\n/&gt;</span>\n</code></pre>\n<pre><code class="language-js"><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {\n <span class="hljs-title function_">setup</span>(<span class="hljs-params"></span>) {\n <span class="hljs-keyword">const</span> text =\n <span class="hljs-string">&quot;That day, I turned twenty-one. In the golden age of my life, I was full of dreams. I wanted to love, to eat, and to instantly transform into one of these clouds, part alight, part darkened. It was only later that I understood life is but a slow, drawn-out process of getting your balls crushed. Day by day, you get older. Day by day, your dreams fade. In the end you are no different from a crushed ox. But I hadn&#x27;t foreseen any of it on my twenty-first birthday. I thought I would be vigorous forever, and that nothing could ever crush me.&quot;</span>;\n <span class="hljs-keyword">return</span> { text };\n },\n};\n</code></pre>\n</div><div class="van-doc-card"><h3 id="custom-collapse-position" tabindex="-1">Custom Collapse Position</h3>\n<ul>\n<li>Collapse the beginning part of the content:</li>\n</ul>\n<pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">van-text-ellipsis</span>\n <span class="hljs-attr">rows</span>=<span class="hljs-string">&quot;1&quot;</span>\n <span class="hljs-attr">:content</span>=<span class="hljs-string">&quot;text&quot;</span>\n <span class="hljs-attr">expand-text</span>=<span class="hljs-string">&quot;expand&quot;</span>\n <span class="hljs-attr">collapse-text</span>=<span class="hljs-string">&quot;collapse&quot;</span>\n <span class="hljs-attr">position</span>=<span class="hljs-string">&quot;start&quot;</span>\n/&gt;</span>\n</code></pre>\n<pre><code class="language-js"><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {\n <span class="hljs-title function_">setup</span>(<span class="hljs-params"></span>) {\n <span class="hljs-keyword">const</span> text =\n <span class="hljs-string">&quot;That day, I turned twenty-one. In the golden age of my life, I was full of dreams. I wanted to love, to eat, and to instantly transform into one of these clouds, part alight, part darkened. It was only later that I understood life is but a slow, drawn-out process of getting your balls crushed. Day by day, you get older. Day by day, your dreams fade. In the end you are no different from a crushed ox. But I hadn&#x27;t foreseen any of it on my twenty-first birthday. I thought I would be vigorous forever, and that nothing could ever crush me.&quot;</span>;\n <span class="hljs-keyword">return</span> { text };\n },\n};\n</code></pre>\n<ul>\n<li>Collapse the middle part of the content:</li>\n</ul>\n<pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">van-text-ellipsis</span>\n <span class="hljs-attr">rows</span>=<span class="hljs-string">&quot;2&quot;</span>\n <span class="hljs-attr">:content</span>=<span class="hljs-string">&quot;text&quot;</span>\n <span class="hljs-attr">expand-text</span>=<span class="hljs-string">&quot;expand&quot;</span>\n <span class="hljs-attr">collapse-text</span>=<span class="hljs-string">&quot;collapse&quot;</span>\n <span class="hljs-attr">position</span>=<span class="hljs-string">&quot;middle&quot;</span>\n/&gt;</span>\n</code></pre>\n<pre><code class="language-js"><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {\n <span class="hljs-title function_">setup</span>(<span class="hljs-params"></span>) {\n <span class="hljs-keyword">const</span> text =\n <span class="hljs-string">&quot;That day, I turned twenty-one. In the golden age of my life, I was full of dreams. I wanted to love, to eat, and to instantly transform into one of these clouds, part alight, part darkened. It was only later that I understood life is but a slow, drawn-out process of getting your balls crushed. Day by day, you get older. Day by day, your dreams fade. In the end you are no different from a crushed ox. But I hadn&#x27;t foreseen any of it on my twenty-first birthday. I thought I would be vigorous forever, and that nothing could ever crush me.&quot;</span>;\n <span class="hljs-keyword">return</span> { text };\n },\n};\n</code></pre>\n</div><div class="van-doc-card"><h3 id="custom-action" tabindex="-1">Custom Action</h3>\n<p>Use <code>action</code> slots to custom action.</p>\n<pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">van-text-ellipsis</span> <span class="hljs-attr">:content</span>=<span class="hljs-string">&quot;text&quot;</span>&gt;</span>\n <span class="hljs-tag">&lt;<span class="hljs-name">template</span> #<span class="hljs-attr">action</span>=<span class="hljs-string">&quot;{ expanded }&quot;</span>&gt;</span>\n {{ expanded ? &#x27;Collapse&#x27; : &#x27;Expand&#x27; }}\n <span class="hljs-tag">&lt;/<span class="hljs-name">template</span>&gt;</span>\n<span class="hljs-tag">&lt;/<span class="hljs-name">van-text-ellipsis</span>&gt;</span>\n</code></pre>\n<pre><code class="language-js"><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {\n <span class="hljs-title function_">setup</span>(<span class="hljs-params"></span>) {\n <span class="hljs-keyword">const</span> text =\n <span class="hljs-string">&#x27;Take your time and be patient. Life itself will eventually answer all those questions it once raised for you.&#x27;</span>;\n <span class="hljs-keyword">return</span> { text };\n },\n};\n</code></pre>\n</div><h2 id="api" tabindex="-1">API</h2>\n<div class="van-doc-card"><h3 id="props" tabindex="-1">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>rows</td>\n<td>Number of rows displayed</td>\n<td><em>number | string</em></td>\n<td><code>1</code></td>\n</tr>\n<tr>\n<td>content</td>\n<td>The text displayed</td>\n<td><em>string</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>expand-text</td>\n<td>Expand operation text</td>\n<td><em>string</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>collapse-text</td>\n<td>Collapse operation text</td>\n<td><em>string</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>dots <code>v4.2.0</code></td>\n<td>Text content of ellipsis</td>\n<td><em>string</em></td>\n<td><code>\'...\'</code></td>\n</tr>\n<tr>\n<td>position <code>v4.6.2</code></td>\n<td>Can be set to <code>start</code> <code>middle</code></td>\n<td><em>string</em></td>\n<td><code>\'end\'</code></td>\n</tr>\n</tbody>\n</table>\n</div><div class="van-doc-card"><h3 id="events" tabindex="-1">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-action</td>\n<td>Emitted when Expand/Collapse 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="methods" tabindex="-1">Methods</h3>\n<p>Use <a href="https://vuejs.org/guide/essentials/template-refs.html" target="_blank">ref</a> to get TextEllipsis instance and call instance methods.</p>\n<table>\n<thead>\n<tr>\n<th>Name</th>\n<th>Description</th>\n<th>Attribute</th>\n<th>Return value</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>toggle</td>\n<td>Toggle expanded status</td>\n<td><em>expanded?: boolean</em></td>\n<td>-</td>\n</tr>\n</tbody>\n</table>\n</div><div class="van-doc-card"><h3 id="slots" tabindex="-1">Slots</h3>\n<table>\n<thead>\n<tr>\n<th>Name</th>\n<th>Description</th>\n<th>SlotProps</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>action <code>v4.8.3</code></td>\n<td>Custom action</td>\n<td><em>{ expanded: boolean }</em></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> {\n <span class="hljs-title class_">TextEllipsisProps</span>,\n <span class="hljs-title class_">TextEllipsisInstance</span>,\n <span class="hljs-title class_">TextEllipsisThemeVars</span>,\n} <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;vant&#x27;</span>;\n</code></pre>\n<p><code>TextEllipsisInstance</code> is the type of component instance:</p>\n<pre><code class="language-ts"><span class="hljs-keyword">import</span> { ref } <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;vue&#x27;</span>;\n<span class="hljs-keyword">import</span> <span class="hljs-keyword">type</span> { <span class="hljs-title class_">TextEllipsisInstance</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">&#x27;vant&#x27;</span>;\n\n<span class="hljs-keyword">const</span> textEllipsisRef = ref&lt;<span class="hljs-title class_">TextEllipsisInstance</span>&gt;();\n\ntextEllipsisRef.<span class="hljs-property">value</span>?.<span class="hljs-title function_">toggle</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-text-ellipsis-action-color</td>\n<td><em>var(--van-blue)</em></td>\n<td>Color of action text</td>\n</tr>\n<tr>\n<td>--van-text-ellipsis-line-height</td>\n<td><em>1.6</em></td>\n<td>Line height of text</td>\n</tr>\n</tbody>\n</table>\n</div>'},null,8,e))}}}]);