<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