mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
2 lines
16 KiB
JavaScript
2 lines
16 KiB
JavaScript
/*! For license information please see 7691.3dbb8ad4.js.LICENSE.txt */
|
|
(self.webpackChunk=self.webpackChunk||[]).push([["7691"],{4115:function(s,n,a){"use strict";a.r(n);var t=a("80681");let l=["innerHTML"];n.default={setup:()=>({html:""}),render:()=>((0,t.wg)(),(0,t.iD)("div",{class:"van-doc-markdown-body",innerHTML:'<h1>TextEllipsis \u6587\u672C\u7701\u7565</h1>\n<div class="van-doc-card"><h3 id="jie-shao" tabindex="-1">\u4ECB\u7ECD</h3>\n<p>\u5BF9\u957F\u6587\u672C\u8FDB\u884C\u7701\u7565\uFF0C\u652F\u6301\u5C55\u5F00/\u6536\u8D77\u3002\u8BF7\u5347\u7EA7 <code>vant</code> \u5230 >= 4.1.0 \u7248\u672C\u6765\u4F7F\u7528\u8BE5\u7EC4\u4EF6\u3002</p>\n</div><div class="van-doc-card"><h3 id="yin-ru" tabindex="-1">\u5F15\u5165</h3>\n<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>\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_">TextEllipsis</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_">TextEllipsis</span>);\n</code></pre>\n</div><h2 id="dai-ma-yan-shi" tabindex="-1">\u4EE3\u7801\u6F14\u793A</h2>\n<div class="van-doc-card"><h3 id="ji-chu-yong-fa" tabindex="-1">\u57FA\u7840\u7528\u6CD5</h3>\n<p>\u9ED8\u8BA4\u5C55\u793A <code>1</code> \u884C\uFF0C\u8D85\u8FC7 <code>1</code> \u884C\u663E\u793A\u7701\u7565\u53F7\u3002</p>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-text-ellipsis</span> <span class="hljs-attr">:content</span>=<span class="hljs-string">"text"</span> /></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 = <span class="hljs-string">'\u6162\u6162\u6765\uFF0C\u4E0D\u8981\u6025\uFF0C\u751F\u6D3B\u7ED9\u4F60\u51FA\u4E86\u96BE\u9898\uFF0C\u53EF\u4E5F\u7EC8\u6709\u4E00\u5929\u4F1A\u7ED9\u51FA\u7B54\u6848\u3002'</span>;\n <span class="hljs-keyword">return</span> { text };\n },\n};\n</code></pre>\n</div><div class="van-doc-card"><h3 id="zhan-kai-shou-qi" tabindex="-1">\u5C55\u5F00/\u6536\u8D77</h3>\n<p>\u8D85\u8FC7\u884C\u6570\u652F\u6301\u5C55\u5F00/\u6536\u8D77\u3002</p>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-text-ellipsis</span> <span class="hljs-attr">:content</span>=<span class="hljs-string">"text"</span> <span class="hljs-attr">expand-text</span>=<span class="hljs-string">"\u5C55\u5F00"</span> <span class="hljs-attr">collapse-text</span>=<span class="hljs-string">"\u6536\u8D77"</span> /></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">'\u4F3C\u6C34\u6D41\u5E74\u662F\u4E00\u4E2A\u4EBA\u6240\u6709\u7684\u4E00\u5207\uFF0C\u53EA\u6709\u8FD9\u4E2A\u4E1C\u897F\uFF0C\u624D\u771F\u6B63\u5F52\u4F60\u6240\u6709\u3002\u5176\u4F59\u7684\u4E00\u5207\uFF0C\u90FD\u662F\u7247\u523B\u7684\u6B22\u5A31\u548C\u4E0D\u5E78\uFF0C\u8F6C\u773C\u95F4\u5C31\u5DF2\u8DD1\u5230\u90A3\u4F3C\u6C34\u6D41\u5E74\u91CC\u53BB\u4E86\u3002'</span>;\n <span class="hljs-keyword">return</span> { text };\n },\n};\n</code></pre>\n</div><div class="van-doc-card"><h3 id="zi-ding-yi-zhan-shi-xing-shu" tabindex="-1">\u81EA\u5B9A\u4E49\u5C55\u793A\u884C\u6570</h3>\n<p>\u901A\u8FC7\u8BBE\u7F6E <code>rows</code> \u9650\u5236\u5C55\u793A\u884C\u6570\u3002</p>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-text-ellipsis</span>\n <span class="hljs-attr">rows</span>=<span class="hljs-string">"3"</span>\n <span class="hljs-attr">:content</span>=<span class="hljs-string">"text"</span>\n <span class="hljs-attr">expand-text</span>=<span class="hljs-string">"\u5C55\u5F00"</span>\n <span class="hljs-attr">collapse-text</span>=<span class="hljs-string">"\u6536\u8D77"</span>\n/></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">'\u90A3\u4E00\u5929\u6211\u4E8C\u5341\u4E00\u5C81\uFF0C\u5728\u6211\u4E00\u751F\u7684\u9EC4\u91D1\u65F6\u4EE3\u3002\u6211\u6709\u597D\u591A\u5962\u671B\u3002\u6211\u60F3\u7231\uFF0C\u60F3\u5403\uFF0C\u8FD8\u60F3\u5728\u4E00\u77AC\u95F4\u53D8\u6210\u5929\u4E0A\u534A\u660E\u534A\u6697\u7684\u4E91\u3002\u540E\u6765\u6211\u624D\u77E5\u9053\uFF0C\u751F\u6D3B\u5C31\u662F\u4E2A\u7F13\u6162\u53D7\u9524\u7684\u8FC7\u7A0B\uFF0C\u4EBA\u4E00\u5929\u5929\u8001\u4E0B\u53BB\uFF0C\u5962\u671B\u4E5F\u4E00\u5929\u5929\u6D88\u5931\uFF0C\u6700\u540E\u53D8\u5F97\u50CF\u6328\u4E86\u9524\u7684\u725B\u4E00\u6837\u3002\u53EF\u662F\u6211\u8FC7\u4E8C\u5341\u4E00\u5C81\u751F\u65E5\u65F6\u6CA1\u6709\u9884\u89C1\u5230\u8FD9\u4E00\u70B9\u3002\u6211\u89C9\u5F97\u81EA\u5DF1\u4F1A\u6C38\u8FDC\u751F\u731B\u4E0B\u53BB\uFF0C\u4EC0\u4E48\u4E5F\u9524\u4E0D\u4E86\u6211\u3002'</span>;\n <span class="hljs-keyword">return</span> { text };\n },\n};\n</code></pre>\n</div><div class="van-doc-card"><h3 id="zi-ding-yi-sheng-lue-wei-zhi" tabindex="-1">\u81EA\u5B9A\u4E49\u7701\u7565\u4F4D\u7F6E</h3>\n<p>\u901A\u8FC7\u8BBE\u7F6E <code>position</code> \u63A7\u5236\u7701\u7565\u4F4D\u7F6E\u3002</p>\n<ul>\n<li>\u5934\u90E8\u7701\u7565\uFF1A</li>\n</ul>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-text-ellipsis</span>\n <span class="hljs-attr">rows</span>=<span class="hljs-string">"1"</span>\n <span class="hljs-attr">:content</span>=<span class="hljs-string">"text"</span>\n <span class="hljs-attr">expand-text</span>=<span class="hljs-string">"\u5C55\u5F00"</span>\n <span class="hljs-attr">collapse-text</span>=<span class="hljs-string">"\u6536\u8D77"</span>\n <span class="hljs-attr">position</span>=<span class="hljs-string">"start"</span>\n/></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">'\u90A3\u4E00\u5929\u6211\u4E8C\u5341\u4E00\u5C81\uFF0C\u5728\u6211\u4E00\u751F\u7684\u9EC4\u91D1\u65F6\u4EE3\u3002\u6211\u6709\u597D\u591A\u5962\u671B\u3002\u6211\u60F3\u7231\uFF0C\u60F3\u5403\uFF0C\u8FD8\u60F3\u5728\u4E00\u77AC\u95F4\u53D8\u6210\u5929\u4E0A\u534A\u660E\u534A\u6697\u7684\u4E91\u3002\u540E\u6765\u6211\u624D\u77E5\u9053\uFF0C\u751F\u6D3B\u5C31\u662F\u4E2A\u7F13\u6162\u53D7\u9524\u7684\u8FC7\u7A0B\uFF0C\u4EBA\u4E00\u5929\u5929\u8001\u4E0B\u53BB\uFF0C\u5962\u671B\u4E5F\u4E00\u5929\u5929\u6D88\u5931\uFF0C\u6700\u540E\u53D8\u5F97\u50CF\u6328\u4E86\u9524\u7684\u725B\u4E00\u6837\u3002\u53EF\u662F\u6211\u8FC7\u4E8C\u5341\u4E00\u5C81\u751F\u65E5\u65F6\u6CA1\u6709\u9884\u89C1\u5230\u8FD9\u4E00\u70B9\u3002\u6211\u89C9\u5F97\u81EA\u5DF1\u4F1A\u6C38\u8FDC\u751F\u731B\u4E0B\u53BB\uFF0C\u4EC0\u4E48\u4E5F\u9524\u4E0D\u4E86\u6211\u3002'</span>;\n <span class="hljs-keyword">return</span> { text };\n },\n};\n</code></pre>\n<ul>\n<li>\u4E2D\u90E8\u7701\u7565\uFF1A</li>\n</ul>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-text-ellipsis</span>\n <span class="hljs-attr">rows</span>=<span class="hljs-string">"2"</span>\n <span class="hljs-attr">:content</span>=<span class="hljs-string">"text"</span>\n <span class="hljs-attr">expand-text</span>=<span class="hljs-string">"\u5C55\u5F00"</span>\n <span class="hljs-attr">collapse-text</span>=<span class="hljs-string">"\u6536\u8D77"</span>\n <span class="hljs-attr">position</span>=<span class="hljs-string">"middle"</span>\n/></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">'\u90A3\u4E00\u5929\u6211\u4E8C\u5341\u4E00\u5C81\uFF0C\u5728\u6211\u4E00\u751F\u7684\u9EC4\u91D1\u65F6\u4EE3\u3002\u6211\u6709\u597D\u591A\u5962\u671B\u3002\u6211\u60F3\u7231\uFF0C\u60F3\u5403\uFF0C\u8FD8\u60F3\u5728\u4E00\u77AC\u95F4\u53D8\u6210\u5929\u4E0A\u534A\u660E\u534A\u6697\u7684\u4E91\u3002\u540E\u6765\u6211\u624D\u77E5\u9053\uFF0C\u751F\u6D3B\u5C31\u662F\u4E2A\u7F13\u6162\u53D7\u9524\u7684\u8FC7\u7A0B\uFF0C\u4EBA\u4E00\u5929\u5929\u8001\u4E0B\u53BB\uFF0C\u5962\u671B\u4E5F\u4E00\u5929\u5929\u6D88\u5931\uFF0C\u6700\u540E\u53D8\u5F97\u50CF\u6328\u4E86\u9524\u7684\u725B\u4E00\u6837\u3002\u53EF\u662F\u6211\u8FC7\u4E8C\u5341\u4E00\u5C81\u751F\u65E5\u65F6\u6CA1\u6709\u9884\u89C1\u5230\u8FD9\u4E00\u70B9\u3002\u6211\u89C9\u5F97\u81EA\u5DF1\u4F1A\u6C38\u8FDC\u751F\u731B\u4E0B\u53BB\uFF0C\u4EC0\u4E48\u4E5F\u9524\u4E0D\u4E86\u6211\u3002'</span>;\n <span class="hljs-keyword">return</span> { text };\n },\n};\n</code></pre>\n</div><div class="van-doc-card"><h3 id="zi-ding-yi-cao-zuo-nei-rong" tabindex="-1">\u81EA\u5B9A\u4E49\u64CD\u4F5C\u5185\u5BB9</h3>\n<p>\u901A\u8FC7\u63D2\u69FD <code>action</code> \u81EA\u5B9A\u4E49\u64CD\u4F5C\u5185\u5BB9\u3002</p>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-text-ellipsis</span> <span class="hljs-attr">:content</span>=<span class="hljs-string">"text"</span>></span>\n <span class="hljs-tag"><<span class="hljs-name">template</span> #<span class="hljs-attr">action</span>=<span class="hljs-string">"{ expanded }"</span>></span>{{ expanded ? '\u6536\u8D77' : '\u5C55\u5F00' }}<span class="hljs-tag"></<span class="hljs-name">template</span>></span>\n<span class="hljs-tag"></<span class="hljs-name">van-text-ellipsis</span>></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 = <span class="hljs-string">'\u6162\u6162\u6765\uFF0C\u4E0D\u8981\u6025\uFF0C\u751F\u6D3B\u7ED9\u4F60\u51FA\u4E86\u96BE\u9898\uFF0C\u53EF\u4E5F\u7EC8\u6709\u4E00\u5929\u4F1A\u7ED9\u51FA\u7B54\u6848\u3002'</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>\u53C2\u6570</th>\n<th>\u8BF4\u660E</th>\n<th>\u7C7B\u578B</th>\n<th>\u9ED8\u8BA4\u503C</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>rows</td>\n<td>\u5C55\u793A\u7684\u884C\u6570</td>\n<td><em>number | string</em></td>\n<td><code>1</code></td>\n</tr>\n<tr>\n<td>content</td>\n<td>\u9700\u8981\u5C55\u793A\u7684\u6587\u672C</td>\n<td><em>string</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>expand-text</td>\n<td>\u5C55\u5F00\u64CD\u4F5C\u7684\u6587\u6848</td>\n<td><em>string</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>collapse-text</td>\n<td>\u6536\u8D77\u64CD\u4F5C\u7684\u6587\u6848</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>\u7701\u7565\u53F7\u7684\u6587\u672C\u5185\u5BB9</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>\u7701\u7565\u4F4D\u7F6E\uFF0C\u53EF\u9009\u503C\u4E3A <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>\u4E8B\u4EF6\u540D</th>\n<th>\u8BF4\u660E</th>\n<th>\u56DE\u8C03\u53C2\u6570</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>click-action</td>\n<td>\u70B9\u51FB\u5C55\u5F00/\u6536\u8D77\u65F6\u89E6\u53D1</td>\n<td><em>event: MouseEvent</em></td>\n</tr>\n</tbody>\n</table>\n</div><div class="van-doc-card"><h3 id="textellipsis-fang-fa" tabindex="-1">TextEllipsis \u65B9\u6CD5</h3>\n<p>\u901A\u8FC7 ref \u53EF\u4EE5\u83B7\u53D6\u5230 TextEllipsis \u5B9E\u4F8B\u5E76\u8C03\u7528\u5B9E\u4F8B\u65B9\u6CD5\uFF0C\u8BE6\u89C1<a href="#/zh-CN/advanced-usage#zu-jian-shi-li-fang-fa" target="_blank">\u7EC4\u4EF6\u5B9E\u4F8B\u65B9\u6CD5</a>\u3002</p>\n<table>\n<thead>\n<tr>\n<th>\u65B9\u6CD5\u540D</th>\n<th>\u8BF4\u660E</th>\n<th>\u53C2\u6570</th>\n<th>\u8FD4\u56DE\u503C</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>toggle</td>\n<td>\u5207\u6362\u6587\u672C\u7684\u5C55\u5F00\u72B6\u6001\uFF0C\u4F20 <code>true</code> \u4E3A\u5C55\u5F00\uFF0C<code>false</code> \u4E3A\u6536\u8D77\uFF0C\u4E0D\u4F20\u53C2\u4E3A\u5207\u6362</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>\u540D\u79F0</th>\n<th>\u8BF4\u660E</th>\n<th>\u53C2\u6570</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>action <code>v4.8.3</code></td>\n<td>\u81EA\u5B9A\u4E49\u64CD\u4F5C</td>\n<td><em>{ expanded: boolean }</em></td>\n</tr>\n</tbody>\n</table>\n</div><div class="van-doc-card"><h3 id="lei-xing-ding-yi" tabindex="-1">\u7C7B\u578B\u5B9A\u4E49</h3>\n<p>\u7EC4\u4EF6\u5BFC\u51FA\u4EE5\u4E0B\u7C7B\u578B\u5B9A\u4E49\uFF1A</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">'vant'</span>;\n</code></pre>\n<p><code>TextEllipsisInstance</code> \u662F\u7EC4\u4EF6\u5B9E\u4F8B\u7684\u7C7B\u578B\uFF0C\u7528\u6CD5\u5982\u4E0B\uFF1A</p>\n<pre><code class="language-ts"><span class="hljs-keyword">import</span> { ref } <span class="hljs-keyword">from</span> <span class="hljs-string">'vue'</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">'vant'</span>;\n\n<span class="hljs-keyword">const</span> textEllipsisRef = ref<<span class="hljs-title class_">TextEllipsisInstance</span>>();\n\ntextEllipsisRef.<span class="hljs-property">value</span>?.<span class="hljs-title function_">toggle</span>();\n</code></pre>\n</div><h2 id="zhu-ti-ding-zhi" tabindex="-1">\u4E3B\u9898\u5B9A\u5236</h2>\n<div class="van-doc-card"><h3 id="yang-shi-bian-liang" tabindex="-1">\u6837\u5F0F\u53D8\u91CF</h3>\n<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>\n<table>\n<thead>\n<tr>\n<th>\u540D\u79F0</th>\n<th>\u9ED8\u8BA4\u503C</th>\n<th>\u63CF\u8FF0</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>\u64CD\u4F5C\u6309\u94AE\u7684\u989C\u8272</td>\n</tr>\n<tr>\n<td>--van-text-ellipsis-line-height</td>\n<td><em>1.6</em></td>\n<td>\u6587\u672C\u7684\u884C\u9AD8</td>\n</tr>\n</tbody>\n</table>\n</div>'},null,8,l))}}}]); |