|
本帖最后由 cin 于 2016-4-26 18:28 编辑
阿里提供了h5版本的实时聊天快速集成方案,可通过简单几句话快速继承它的实时聊天:
<!DOCTYPE html> <html>
<head></head>
<body>
<div id="J_demo" style="width:300px;height:300px;">
</div>
</body>
<!-- IE8及以下支持JSON -->
<!--[if lt IE 9]>
<script src="https://g.alicdn.com/aliww/ww/json/json.js" charset="utf-8"></script>
<![endif]-->
<!-- 自动适配移动端与pc端 -->
<script src="https://g.alicdn.com/aliww/??h5.imsdk/2.1.0/scripts/yw/wsdk.js,h5.openim.kit/0.3.7/scripts/kit.js" charset="utf-8">
</script>
<script>
window.onload = function(){
WKIT.init({
uid: 'ww1',
appkey: 23015524,
credential: '123456',
touid: '你的e客服主账号', // 在百川控制台设置的E客服账号
sendMsgToCustomService: true });
}
</script>
</html>
以上代码在html中可正常显示,现在我把它放入wex5中,希望使用w文件进行模块化管理,代码参考了百度地图的编码方式,如下:
define(function(require){
var $ = require("jquery");
var justep = require("$UI/system/lib/justep");
var Model = function(){
this.callParent();
};
Model.prototype.onLoad = function(){
var id = this.getIDByXID("div1");
require([ 'https://g.alicdn.com/aliww/??h5.imsdk/2.1.0/scripts/yw/wsdk.js,h5.openim.kit/0.3.7/scripts/kit.js' ], function() { WKIT.init({
uid: 'ww1',
appkey: 23015524,
credential: '123456',
touid: 'ww2',
logo: 'http://img.alicdn.com/tps/i3/TB12LD9IFXXXXb3XpXXSyFWJXXX-82-82.png',
pluginUrl: 'http://www.taobao.com/market/seller/openim/plugindemo.php',
container: id,
width: 300,
height: 300
});
});
};
return Model;
});
运行时,控制台提示:Uncaught TypeError: Cannot read property 'cssText' of undefined
怀疑是require引用的js未能进一步引用其js在服务端相关的css文件所致?请问该如何解决,谢谢!
|
|