Closed LJG-V closed 2 years ago
已收到
我是通过源码中增加属性avatar实现的,在两个方法中添加,然后添加弹幕数据时有选择的增加属性就好了
function CoreComment(parent, init) {
...
if (init.hasOwnProperty('avatar')) {
this.avatar = init['avatar']
}
...
}
CoreComment.prototype.init = function(recycle) {
...
if(this.avatar) {
const avatar = document.createElement('img');
avatar.src = this.avatar;
this.dom.appendChild(avatar)
}
...
}
基本上就是靠上面这么个方法去做。当然如果在用 TypeScript 可以直接改 src/core/Comment.ts
里面的对应方法(或者创造一个子类来加这个功能),然后重新编译即可。
类似一条弹幕: 【img】文本