使用uni-app实现弹幕功能及滚动效果

发布时间:2024年01月12日
<template>
  <view class="container">
    <view class="bullet-container">
      <view v-for="(bullet, index) in bulletList" :key="index" class="bullet-item">
        {
  { bullet }}
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      bulletList: ["弹幕1", "弹幕2", "弹幕3", "弹幕4", "弹幕5"],
    };
  },
  mounted() {
    this.startBulletAnimation();
  },
  methods: {
    startBulletAnimation() {
      const bulletContainer = uni.createSelectorQuery().select(".bullet-container");
      bulletContainer.boundingClientRect().exec((rect) => {
        const containerHeight = rect[0].height;
        const bulletItems = uni.createSelectorQuery().selectAll(".bullet-item");
        bulletItems.boundingClientRect().exec((rect
文章来源:https://blog.csdn.net/cyj0919/article/details/135547354
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。