微信小程序使用realtime时 图片信息出错, TypeError: ImageMessage is not a constructor.
文本信息 TextMessage 成功,请大佬看看什么原因
按文档引入的包
const AV = require('./libs/leancloud-storage.js');
const {
Realtime,
TextMessage,
setAdapters,
Event,
} = require('./libs/leancloud-realtime.js');
const {
TypedMessagesPlugin,
ImageMessage
} = require('./libs/typed-messages.min.js');
const adapters = require('./libs/leancloud-adapters-weapp.js');
AV.setAdapters(adapters); // 为存储 SDK 设置 adapters
setAdapters(adapters); // 为即时通讯 SDK 设置 adapters
图片信息发送代码入下:
// 从网络链接直接构建一个图像消息
var file = new File.withURL('萌妹子', 'http://pic2.zhimg.com/6c10e6053c739ed0ce676a0aff15cf1c.gif');
file.save().then(function () {
var message = new ImageMessage(file);
message.setText('萌妹子一枚');
return conversation.send(message);
}).then(function () {
console.log('发送成功');
}).catch(console.error.bind(console));