qcode
  • 创作工场专业版,一问多答!更智能、更完整、更原创
  • 这是一个超强内容创作平台,它会写文章、做设计、绘图、敲代码,有问必答!
🔥点击使用-高级专业版🔥

vue写一个弹幕播放

时间2023-03-29 10:06:32 提问来自 江苏省淮安市 的网友 分类创作 浏览512
器 ```html <template> <div> <div class="container"> <span v-for="(item,index) in barrageList" :key="index" class="barrage-item">{{ item.content }}</span> </div> </div> </template> <script type="text/ecmascript-6"> export default { data() { return { barrageList: [], // 弹幕列表数据 } }, methods: { // 添加一条弹幕数据到弹幕列表中,参数为一个对象,包含内容等信息,如{ content: 'xxx' } 。返回值是新增的弹幕在弹幕列表中的索引位置。 addBarrage(barrage) { this.barrageList.push(barrage); // 向弹幕列表中添加一条新的数据。 return this.barrageList.length - 1; // 返回新增的弹幕在弹幕列表中的索引位置。 },                      // 移除一条或多条已存在于弹幕列表中的数据,参数为要移除的元素或元素们所处于的位置(即Index)。返回值是被成功从此处被“splice”出去的元素们所形成的Array。              removeBarragesByIndex(indices) {         let removed = [];         if (Array.isArray(indices)) {           for (let i = 0; i < indices.length; i++) {             let index = indices[i];             if (index >= 0 && index <= this.barrageList.length - 1) {               removed = removed.concat(this.barrageList.splice(index, 1));             }           }         } else if (typeof indices === 'number'){           if (indices >= 0 && indices <= this.barrageList - 1 ){                                                                                                                                                                  removed = this.$removeAtIndexAndReturnRemovedItemFromArray(this.$data, indices);                                                                            }       } else {} // do nothing return removed; }, }, created() {} }; </script> ```

点击这里,进行内容创作

创作工场 免责声明:
以上内容除特别注明外均来源于网友提问,创作工场回答,未经许可,严谨转载。
点击这里>>使用🔥专业版,更聪明、更完整、更原创!

上一篇 帮忙给公司IT手册分享系列邮件起个主题 下一篇 会泽县当前提升耕地质量实际情况、面临的困难问题及对策建议