mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
2 lines
14 KiB
JavaScript
2 lines
14 KiB
JavaScript
/*! For license information please see 695.6c3630f9.js.LICENSE.txt */
|
|
(self.webpackChunk=self.webpackChunk||[]).push([["695"],{65882:function(s,a,n){"use strict";n.r(a);var t=n("80681");let l=["innerHTML"];a.default={setup:()=>({html:""}),render:()=>((0,t.wg)(),(0,t.iD)("div",{class:"van-doc-markdown-body",innerHTML:'<h1>Barrage \u5F39\u5E55</h1>\n<div class="van-doc-card"><h3 id="jie-shao" tabindex="-1">\u4ECB\u7ECD</h3>\n<p>\u5B9E\u73B0\u89C2\u770B\u89C6\u9891\u65F6\u5F39\u51FA\u7684\u8BC4\u8BBA\u6027\u5B57\u5E55\u529F\u80FD\u3002\u8BF7\u5347\u7EA7 <code>vant</code> \u5230 >= 4.4.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_">Barrage</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_">Barrage</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>\u53EF\u4EE5\u901A\u8FC7 <code>v-model</code> \u53CC\u5411\u7ED1\u5B9A\u5F39\u5E55\u6570\u636E\uFF0C<code>Barrage</code> \u4F1A\u5728\u7EC4\u4EF6\u533A\u57DF\u5185\u64AD\u653E\u6587\u5B57\u5F39\u5E55\uFF0C\u4F7F\u7528\u6570\u7EC4\u6570\u636E <code>push()</code> \u53EF\u4EE5\u53D1\u9001\u5F39\u5E55\u6587\u5B57\u3002</p>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-barrage</span> <span class="hljs-attr">v-model</span>=<span class="hljs-string">"list"</span>></span>\n <span class="hljs-tag"><<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"video"</span> <span class="hljs-attr">style</span>=<span class="hljs-string">"width: 100%; height: 150px"</span>></span><span class="hljs-tag"></<span class="hljs-name">div</span>></span>\n<span class="hljs-tag"></<span class="hljs-name">van-barrage</span>></span>\n<span class="hljs-tag"><<span class="hljs-name">van-space</span> <span class="hljs-attr">style</span>=<span class="hljs-string">"margin-top: 10px"</span>></span>\n <span class="hljs-tag"><<span class="hljs-name">van-button</span> @<span class="hljs-attr">click</span>=<span class="hljs-string">"add"</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"primary"</span> <span class="hljs-attr">size</span>=<span class="hljs-string">"small"</span>></span> \u5F39\u5E55 <span class="hljs-tag"></<span class="hljs-name">van-button</span>></span>\n<span class="hljs-tag"></<span class="hljs-name">van-space</span>></span>\n</code></pre>\n<pre><code class="language-ts"><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> defaultList = [\n { <span class="hljs-attr">id</span>: <span class="hljs-number">100</span>, <span class="hljs-attr">text</span>: <span class="hljs-string">'\u8F7B\u91CF'</span> },\n { <span class="hljs-attr">id</span>: <span class="hljs-number">101</span>, <span class="hljs-attr">text</span>: <span class="hljs-string">'\u53EF\u5B9A\u5236\u7684'</span> },\n { <span class="hljs-attr">id</span>: <span class="hljs-number">102</span>, <span class="hljs-attr">text</span>: <span class="hljs-string">'\u79FB\u52A8\u7AEF'</span> },\n { <span class="hljs-attr">id</span>: <span class="hljs-number">103</span>, <span class="hljs-attr">text</span>: <span class="hljs-string">'Vue'</span> },\n { <span class="hljs-attr">id</span>: <span class="hljs-number">104</span>, <span class="hljs-attr">text</span>: <span class="hljs-string">'\u7EC4\u4EF6\u5E93'</span> },\n { <span class="hljs-attr">id</span>: <span class="hljs-number">105</span>, <span class="hljs-attr">text</span>: <span class="hljs-string">'VantUI'</span> },\n { <span class="hljs-attr">id</span>: <span class="hljs-number">106</span>, <span class="hljs-attr">text</span>: <span class="hljs-string">'666'</span> },\n ];\n\n <span class="hljs-keyword">const</span> list = <span class="hljs-title function_">ref</span>([...defaultList]);\n <span class="hljs-keyword">const</span> <span class="hljs-title function_">add</span> = (<span class="hljs-params"></span>) => {\n list.<span class="hljs-property">value</span>.<span class="hljs-title function_">push</span>({ <span class="hljs-attr">id</span>: <span class="hljs-title class_">Math</span>.<span class="hljs-title function_">random</span>(), <span class="hljs-attr">text</span>: <span class="hljs-string">'Barrage'</span> });\n };\n\n <span class="hljs-keyword">return</span> { list, add };\n },\n};\n</code></pre>\n</div><div class="van-doc-card"><h3 id="mo-ni-shi-pin-dan-mu" tabindex="-1">\u6A21\u62DF\u89C6\u9891\u5F39\u5E55</h3>\n<p>\u8BBE\u7F6E <code>auto-play</code> \u4E3A <code>false</code> \u5C5E\u6027\u540E\uFF0C\u9700\u8981\u4F7F\u7528 <code>play()</code> \u8FDB\u884C\u5F39\u5E55\u64AD\u653E\uFF0C\u6682\u505C\u53EF\u4EE5\u4F7F\u7528 <code>pause()</code> \u5B9E\u73B0\u3002</p>\n<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">van-barrage</span> <span class="hljs-attr">v-model</span>=<span class="hljs-string">"list"</span> <span class="hljs-attr">ref</span>=<span class="hljs-string">"barrage"</span> <span class="hljs-attr">:auto-play</span>=<span class="hljs-string">"false"</span>></span>\n <span class="hljs-tag"><<span class="hljs-name">div</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"video"</span> <span class="hljs-attr">style</span>=<span class="hljs-string">"width: 100%; height: 150px"</span>></span><span class="hljs-tag"></<span class="hljs-name">div</span>></span>\n<span class="hljs-tag"></<span class="hljs-name">van-barrage</span>></span>\n<span class="hljs-tag"><<span class="hljs-name">van-space</span> <span class="hljs-attr">style</span>=<span class="hljs-string">"margin-top: 10px"</span>></span>\n <span class="hljs-tag"><<span class="hljs-name">van-button</span> @<span class="hljs-attr">click</span>=<span class="hljs-string">"add"</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"primary"</span> <span class="hljs-attr">size</span>=<span class="hljs-string">"small"</span> <span class="hljs-attr">:disabled</span>=<span class="hljs-string">"!isPlay"</span>></span>\n \u5F39\u5E55\n <span class="hljs-tag"></<span class="hljs-name">van-button</span>></span>\n <span class="hljs-tag"><<span class="hljs-name">van-button</span> @<span class="hljs-attr">click</span>=<span class="hljs-string">"toggle()"</span> <span class="hljs-attr">size</span>=<span class="hljs-string">"small"</span>></span>\n {{ isPlay ? '\u6682\u505C' : '\u5F00\u59CB' }}\n <span class="hljs-tag"></<span class="hljs-name">van-button</span>></span>\n<span class="hljs-tag"></<span class="hljs-name">van-space</span>></span>\n</code></pre>\n<pre><code class="language-ts"><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> defaultList = [\n { <span class="hljs-attr">id</span>: <span class="hljs-number">100</span>, <span class="hljs-attr">text</span>: <span class="hljs-string">'\u8F7B\u91CF'</span> },\n { <span class="hljs-attr">id</span>: <span class="hljs-number">101</span>, <span class="hljs-attr">text</span>: <span class="hljs-string">'\u53EF\u5B9A\u5236\u7684'</span> },\n { <span class="hljs-attr">id</span>: <span class="hljs-number">102</span>, <span class="hljs-attr">text</span>: <span class="hljs-string">'\u79FB\u52A8\u7AEF'</span> },\n { <span class="hljs-attr">id</span>: <span class="hljs-number">103</span>, <span class="hljs-attr">text</span>: <span class="hljs-string">'Vue'</span> },\n { <span class="hljs-attr">id</span>: <span class="hljs-number">104</span>, <span class="hljs-attr">text</span>: <span class="hljs-string">'\u7EC4\u4EF6\u5E93'</span> },\n { <span class="hljs-attr">id</span>: <span class="hljs-number">105</span>, <span class="hljs-attr">text</span>: <span class="hljs-string">'VantUI'</span> },\n { <span class="hljs-attr">id</span>: <span class="hljs-number">106</span>, <span class="hljs-attr">text</span>: <span class="hljs-string">'666'</span> },\n ];\n\n <span class="hljs-keyword">const</span> list = <span class="hljs-title function_">ref</span>([...defaultList]);\n <span class="hljs-keyword">const</span> barrage = ref<<span class="hljs-title class_">BarrageInstance</span>>();\n <span class="hljs-keyword">const</span> <span class="hljs-title function_">add</span> = (<span class="hljs-params"></span>) => {\n list.<span class="hljs-property">value</span>.<span class="hljs-title function_">push</span>({ <span class="hljs-attr">id</span>: <span class="hljs-title class_">Math</span>.<span class="hljs-title function_">random</span>(), <span class="hljs-attr">text</span>: <span class="hljs-string">'Barrage'</span> });\n };\n\n <span class="hljs-keyword">const</span> [isPlay, toggle] = <span class="hljs-title function_">useToggle</span>(<span class="hljs-literal">false</span>);\n\n <span class="hljs-title function_">watch</span>(isPlay, <span class="hljs-function">() =></span> {\n <span class="hljs-keyword">if</span> (isPlay.<span class="hljs-property">value</span>) barrage.<span class="hljs-property">value</span>?.<span class="hljs-title function_">play</span>();\n <span class="hljs-keyword">else</span> barrage.<span class="hljs-property">value</span>?.<span class="hljs-title function_">pause</span>();\n });\n\n <span class="hljs-keyword">return</span> { list, barrage, isPlay, toggle, add };\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>v-model</td>\n<td>\u5F39\u5E55\u6570\u636E</td>\n<td><em>BarrageItem[]</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>auto-play</td>\n<td>\u662F\u5426\u81EA\u52A8\u64AD\u653E\u5F39\u5E55</td>\n<td><em>boolean</em></td>\n<td><code>true</code></td>\n</tr>\n<tr>\n<td>rows</td>\n<td>\u5F39\u5E55\u6587\u5B57\u884C\u6570</td>\n<td><em>number | string</em></td>\n<td><code>4</code></td>\n</tr>\n<tr>\n<td>top</td>\n<td>\u5F39\u5E55\u6587\u5B57\u533A\u57DF\u9876\u90E8\u95F4\u8DDD\uFF0C\u5355\u4F4D <code>px</code></td>\n<td><em>number | string</em></td>\n<td><code>10</code></td>\n</tr>\n<tr>\n<td>duration</td>\n<td>\u5F39\u5E55\u6587\u5B57\u6ED1\u8FC7\u5BB9\u5668\u7684\u65F6\u95F4\uFF0C\u5355\u4F4D <code>ms</code></td>\n<td><em>number | string</em></td>\n<td><code>4000</code></td>\n</tr>\n<tr>\n<td>delay</td>\n<td>\u5F39\u5E55\u52A8\u753B\u5EF6\u65F6\uFF0C\u5355\u4F4D <code>ms</code></td>\n<td><em>number</em></td>\n<td><code>300</code></td>\n</tr>\n</tbody>\n</table>\n</div><div class="van-doc-card"><h3 id="fang-fa" tabindex="-1">\u65B9\u6CD5</h3>\n<p>\u901A\u8FC7 ref \u53EF\u4EE5\u83B7\u53D6\u5230 Barrage \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>play</td>\n<td>\u64AD\u653E\u5F39\u5E55</td>\n<td>-</td>\n<td>-</td>\n</tr>\n<tr>\n<td>pause</td>\n<td>\u6682\u505C\u5F39\u5E55</td>\n<td>-</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</tr>\n</thead>\n<tbody>\n<tr>\n<td>default</td>\n<td>\u5F39\u5E55\u7EC4\u4EF6\u5B50\u5143\u7D20</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> { <span class="hljs-title class_">BarrageProps</span>, <span class="hljs-title class_">BarrageItem</span>, <span class="hljs-title class_">BarrageInstance</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">'vant'</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-barrage-font-size</td>\n<td><em>16px</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-barrage-space</td>\n<td><em>10px</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-barrage-color</td>\n<td><em>var(--van-white)</em></td>\n<td>-</td>\n</tr>\n<tr>\n<td>--van-barrage-font</td>\n<td><em>inherit</em></td>\n<td>-</td>\n</tr>\n</tbody>\n</table>\n</div>'},null,8,l))}}}]); |