vue 弹幕插件
一、概述
弹幕是中国较受欢迎的弹幕展示方式。
先来看一下效果图
二、安装插件
npm install vue-baberrage -D
官方链接:https://blog.chenhaotaishuaile.com/vue-baberrage/
中文文档:https://github.com/superhos/vue-baberrage/blob/master/docs/zh/README.md
三、演示效果
test.vue

<template> <div class="barrages-drop"> <vue-baberrage :isShow="barrageIsShow" :barrageList="barrageList" :maxWordCount="maxWordCount" :throttleGap="throttleGap" :loop="barrageLoop" :boxHeight="boxHeight" :messageHeight="messageHeight" > </vue-baberrage> </div> </template> <script> import Vue from 'vue'; import { vueBaberrage, MESSAGE_TYPE } from 'vue-baberrage'; Vue.use(vueBaberrage); export default { name: 'Barrages', data() { return { msg: '~', barrageIsShow: true, messageHeight: 3, boxHeight: 150, barrageLoop: true, maxWordCount: 3, throttleGap: 5000, barrageList: [] }; }, mounted() { this.addToList(); }, methods: { addToList() { let list = [ { id: 1, avatar: 'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3064584167,3502823640&fm=26&gp=0.jpg', msg: "人生若只如初见", time: 1, barrageStyle: 'red' }, { id: 2, avatar: 'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3064584167,3502823640&fm=26&gp=0.jpg', msg: "何事秋风悲画扇", time: 2, barrageStyle: 'green' }, { id: 3, avatar: 'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3064584167,3502823640&fm=26&gp=0.jpg', msg: "等闲变却故人心", time: 3, barrageStyle: 'normal' }, { id: 4, avatar: 'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3064584167,3502823640&fm=26&gp=0.jpg', msg: "却道故人心易变", time: 4, barrageStyle: 'blue' }, { id: 5, avatar: 'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3064584167,3502823640&fm=26&gp=0.jpg', msg: "骊山语罢清宵半", time: 5, barrageStyle: 'yellow' }, { id: 6, avatar: 'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3064584167,3502823640&fm=26&gp=0.jpg', msg: "泪雨霖铃终不怨", time: 6, barrageStyle: 'normal' }, { id: 7, avatar: 'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3064584167,3502823640&fm=26&gp=0.jpg', msg: "何如薄幸锦衣郎", time: 7, barrageStyle: 'red' }, { id: 8, avatar: 'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=3064584167,3502823640&fm=26&gp=0.jpg', msg: "比翼连枝当日愿", time: 8, barrageStyle: 'normal' }, ]; list.forEach((v) => { this.barrageList.push({ id: v.id, avatar: v.avatar, msg: v.msg, time: v.time, type: MESSAGE_TYPE.NORMAL, barrageStyle: v.barrageStyle }); }); } } }; </script> <style lang="scss" scoped> .barrages-drop { /deep/ .baberrage-lane{ /deep/ .blue .normal{ border-radius: 100px; background: #e6ff75; color: #fff; } /deep/ .green .normal{ border-radius: 100px; background: #75ffcd; color: #fff; } /deep/ .red .normal{ border-radius: 100px; background: #e68fba; color: #fff; } /deep/ .yellow .normal{ border-radius: 100px; background: #dfc795; color: #fff; } .baberrage-stage { position: absolute; width: 100%; height: 212px; overflow: hidden; top: 0; margin-top: 130px; } } } </style>
关于如何使用,在中文文档中有详细说明,这里不做重复。
本文参考链接:
分类:
python 运维开发
标签:
vue
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix