itap
itap
  • 发布:2023-02-17 17:05
  • 更新:2024-12-01 17:04
  • 阅读:606

uni-im 微信小程序发送消息后返回Cannot read property 'slice'

分类:uniCloud

{"success":false,"error":{"code":"FunctionBizError","message":"Cannot read property 'slice' of undefined","httpStatus":200}}

原因是微信小程序,用微信登录后未设置昵称,导致后端判断不了,增加一个判断即可

云对象 uni-im-co/index.obj.js

443行

let title = (nickname || username || email || mobile).slice(0, 20)

修改为

        let title = (nickname || username || email || mobile)  
        if(title!=undefined){  
                    title = title.slice(0, 20)  
                }

456行

title: title.slice(0, 20), // "收到im消息,离线时显示的标题",

修改为

title: title, // "收到im消息,离线时显示的标题"
1 关注 分享
Lvzz

要回复文章请先登录注册

Lvzz

Lvzz

mark
2024-12-01 17:04