效果:javascript
下載vue
優化版下載:java
https://pan.baidu.com/s/1mvKGwJsBjXd2hvvi5Rp9pAweb
用法:數組
import barrage from '../components/barrage.vue' <barrage :linecount="3" :data="textlist"></barrage> //linecount屬性表示顯示幾行彈幕 //textlist數據格式爲字符串數組
注: 1:barrage元素父容器 必須設置相對定位或絕對定位 2:須要添加window.RAF方法:
在beforeCreate方法裏面加上:
window.RAF = (function(){ return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback) {window.setTimeout(callback, 1000 / 60); }; })(); if (!window.cancelAnimationFrame) window.cancelAnimationFrame = function(id) { clearTimeout(id); };