为啥我的弹幕发送不出去
发布于 6 年前 作者 xyang 2899 次浏览 来自 问答

Page({

    onReady() {

        this.videoCtx = wx.createVideoContext(‘myVideo’)

    },

    bindSendDanmu: function () {

        this.videoContext.sendDanmu({

            text: this.inputValue,

            color: getRandomColor()

        })

    }

})

一旦我点击发送弹幕按钮就报错:

thirdScriptError

    Cannot read property ‘sendDanmu’ of undefined;at pages/cover-view/cover-view page bindSendDanmu function

    TypeError: Cannot read property ‘sendDanmu’ of undefined

如果使用 wx.createVideoContext(‘myVideo’).sendDanmu({}) 就没问题

WXML:

1 回复

你创建的对象名叫  videoCtx   下面又用this.videoContext肯定报错啊  改成这样就行了  this.videoCtx.sendDanmu

回到顶部