/*! For license information please see 1722.aac6dcd9.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["1722"],{82726: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:'
To realize the critical subtitle function when watching the video. Please upgrade vant
to >= v4.4.0 before using this component.
Register component globally via app.use
, refer to Component Registration for more registration ways.
import { createApp } from 'vue';\nimport { Barrage } from 'vant';\n\nconst app = createApp();\napp.use(Barrage);\n
\n<van-barrage v-model="list">\n <div class="video" style="width: 100%; height: 150px"></div>\n</van-barrage>\n<van-space style="margin-top: 10px">\n <van-button @click="add" type="primary" size="small"> barrage </van-button>\n</van-space>\n
\nexport default {\n setup() {\n const defaultList = [\n { id: 100, text: 'Lightweight' },\n { id: 101, text: 'Customizable' },\n { id: 102, text: 'Mobile' },\n { id: 103, text: 'Vue' },\n { id: 104, text: 'Library' },\n { id: 105, text: 'VantUI' },\n { id: 106, text: '666' },\n ];\n\n const list = ref([...defaultList]);\n const add = () => {\n list.value.push({ id: Math.random(), text: 'Barrage' });\n };\n return { list, add };\n },\n};\n
\n<van-barrage v-model="list" ref="barrage" :auto-play="false">\n <div class="video" style="width: 100%; height: 150px"></div>\n</van-barrage>\n<van-space style="margin-top: 10px">\n <van-button @click="add" type="primary" size="small" :disabled="!isPlay">\n barrage\n </van-button>\n <van-button @click="toggle()" size="small">\n {{ isPlay ? 'pause' : 'play' }}\n </van-button>\n</van-space>\n
\nexport default {\n setup() {\n const defaultList = [\n { id: 100, text: 'Lightweight' },\n { id: 101, text: 'Customizable' },\n { id: 102, text: 'Mobile' },\n { id: 103, text: 'Vue' },\n { id: 104, text: 'Library' },\n { id: 105, text: 'VantUI' },\n { id: 106, text: '666' },\n ];\n\n const list = ref([...defaultList]);\n const barrage = ref<BarrageInstance>();\n const add = () => {\n list.value.push({ id: Math.random(), text: 'Barrage' });\n };\n\n const [isPlay, toggle] = useToggle(false);\n\n watch(isPlay, () => {\n if (isPlay.value) barrage.value?.play();\n else barrage.value?.pause();\n });\n\n return { list, barrage, isPlay, toggle, add };\n },\n};\n
\nAttribute | \nDescription | \nType | \nDefault | \n
---|---|---|---|
v-model | \nBarrage data | \nBarrageItem[] | \n- | \n
auto-play | \nWhether to play the bullet screen automatically | \nboolean | \ntrue | \n
rows | \nThe number of lines of text | \nnumber | string | \n4 | \n
top | \nSpacing between the top of the barrage area, unit px | \nnumber | string | \n10 | \n
duration | \nText animation duration, unit ms | \nnumber | string | \n4000 | \n
delay | \nBarrage animation delay, unit ms | \nnumber | \n300 | \n
Use ref to get Barrage instance and call instance methods.
\nName | \nDescription | \nAttribute | \nReturn value | \n
---|---|---|---|
play | \nPlay barrage | \n- | \n- | \n
pause | \nPause barrage | \n- | \n- | \n
Name | \nDescription | \n
---|---|
default | \nDefault slot | \n
The component exports the following type definitions:
\nimport type { BarrageProps, BarrageItem, BarrageInstance } from 'vant';\n
\nThe component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.
\nName | \nDefault Value | \nDescription | \n
---|---|---|
--van-barrage-font-size | \n16px | \n- | \n
--van-barrage-space | \n10px | \n- | \n
--van-barrage-color | \nvar(--van-white) | \n- | \n
--van-barrage-font | \ninherit | \n- | \n