我实际上正在为我的商业公司开发一个定制的ERP,我需要使用Converse.js实现基于xmpp网络的聊天应用程序。
但是我找不到用api管理事件回调的任何解决方案。
根据这些文档,应使用以下语法:
_converse.api.listen.on('message', function (messageXML) { ... });
或
converse.api.listen.on('message', function (messageXML) { ... });
但是"converse.api“这个词还不确定
Converse.js版本6.0.1
我希望你的宝贵帮助。
抱歉,我的英语不好
发布于 2020-07-12 13:21:17
Conerse.js有一个公共的(即全局访问的) API,它可以通过逆流全局访问。最常用的方法是converse.initialize。
然而,大多数API方法仅限于私有(即封闭) 逆流对象(注意前面的下划线),并且可以通过converse.api获得。
只有当您访问_converse.api时才能访问注册插件。
例如:
converse.plugins.add('myplugin', {
initialize: function () {
// This method gets called once converse.initialize has been called
// and the plugin itself has been loaded.
// Inside this method, you have access to the closured
// _converse object as an attribute on "this".
// E.g. this._converse
const { api } = this._converse;
api.listen.on('message', function (messageXML) { ... });
}
});https://stackoverflow.com/questions/62246021
复制相似问题