<template>
<vue-danmaku ref="danmaku" v-model="danmus" use-slot loop randomChannel autoplay
style="height:200px; width:100%;" @play-end="end" :speeds="40" :channels="3">
<!-- 循环 -->
<template slot="dm" slot-scope="{ danmu }">
<!-- 弹幕值 -->
<div>{{ danmu.guestbookContext }}</div>
</template>
</vue-danmaku>
</template>
<script>
export default {
import { InsertGuestbook, listGuestbook } from "@/api/webapi/guestbook";
name: "index",
data() {
return {
danmus: [],
},
created() {
this.getGuestbook();
},
methods: {
end() {
console.log(this.$refs.danmaku);
},
// 查询留言
getGuestbook() {
listGuestbook().then((res) => {
this.danmus = res.rows;
});
},
}
}
</script>