收藏
回答

为啥我的弹幕发送不出去

框架类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 wx.createVideoContext 工具 6.5.6 1.9.1

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:


回答关注问题邀请回答
收藏

3 个回答

  • 酉酉
    酉酉
    2023-06-10

    看看代码里是否有两个onReady方法

    2023-06-10
    有用
    回复
  • 李莉
    李莉
    2020-10-27

    没有用,我的代码中就是 this.videoCtx.sendDanmu,一样不起作用,还是会报错,所以请问各位大侠有解决方案吗?

    2020-10-27
    有用
    回复
  • Geek
    Geek
    2018-03-30

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

    2018-03-30
    有用
    回复 1
    • 卟LI卟棄
      卟LI卟棄
      2023-12-01
      弹幕初始化从数据库查询出来无法展示什么原因
      2023-12-01
      回复
登录 后发表内容