MM们
去看了一下Strophe的源码。不知道你用的什么版本的。我看源码最后是这样的function (Strophe, build, msg, iq, pres) { window.Strophe = Strophe; window.$build = build; window.$msg = msg;
window.$iq = iq; window.$pres = pres;
};小程序中宿主环境不是浏览器,所以没有window。这样写当然是不行的。你可以尝试修改为function (Strophe, build, msg, iq, pres) { var global = {}
global.Strophe = Strophe;
global.$build = build;
global.$msg = msg;
global.$iq = iq;
global.$pres = pres; module.exports = global
};使用的时候:var Strophe = require('./pathStrophe.js').Strophe注:小程序和web编程是有区别的。我看了一下这个库的源码,使用了很多document, xhr之类的,这些是不支持的哦。可以查阅官方文档。