首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >uniapp中TRTC使用报错什么原因?

uniapp中TRTC使用报错什么原因?

提问于 2024-09-04 10:12:19
回答 0关注 0查看 10

js代码

代码语言:txt
复制
const TUICallKit = uni.requireNativePlugin("TencentCloud-TUICallKit");
// #endif
import openTool from './openTool.vue'
export default {
    emits: ['tryagin','longpressItem'],
    name: 'chat-item',
    components:{
        openTool
    },
    props: {
        item: {
            type: Object,
            default: {}
        },
        talkTo: {
            type: Object,
            default: {}
        },
        itemKey: {
            type: Number
        },
        longTapItemKey: {
            type: [Number,String],
            default:''
        }
    },
    watch:{
        longTapItemKey(v){
            if(this.itemKey==v){
                this.$refs['toolx'+v].showTab();
            }
        }
    },
    data() {
        return {
            innerAudioContext:'',
            paused:false,
            showTrs:false,
        };
    },
    methods: {
        sendVoiceCall(){
            //发起语音
            uni.showLoading({
                title:'发起语音通话'
            })
            var formdata={
                userId: this.talkTo.userId, 
                msgType: "TRTC_VOICE_START", 
                content: "TRTC_VOICE_START" 
            }
            this.$http.request({
                url: '/chat/sendMsg',
                method: 'POST',
                data: JSON.stringify(formdata),
                success: (res) => {
                    if(res.data.code=='200'){
                        if(res.data.data.status!=='0'){
                            uni.showToast({
                                title:res.data.data.statusLabel,
                                icon:'none'
                            })
                            return
                        }
                        var userInfo=res.data.data.userInfo
                        var data={
                            userId:userInfo.userId,
                            trtcId:userInfo.trtcId,
                            nickName:userInfo.nickName,
                            portrait:userInfo.portrait,
                            startTime:new Date().getTime(),
                            type:'audio'
                        }
                        uni.setStorage({
                            key: 'call',
                            data: JSON.stringify(data),
                            success: function () {
                                console.log('success');
                                TUICallKit.call({
                                    userID: userInfo.trtcId,
                                    type: 1
                                })
                            }
                        });
                        
                    }
                }
            });
        },
}

插件用的是hbr插件市场最新版的TencentCloud-TUICallKit;

点击发起通话后一直提示报错

09:44:25.832 TypeError: Cannot read property 'call' of undefined;

没搞明白TUICallKit.call 调用call发起通话为什么会报错,

请问这个是哪里的问题呢?

回答

和开发者交流更多问题细节吧,去 写回答
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档