目前APPCAN真机调试时,输出日志到IDE是比较蛋疼的。。。现在共享我自己一直在用的方法
前提要保证IDE所在电脑的IP段与手机的IP段是一致的。
1.首先在config.xml里配置允许真机调试,设置调试服务器地址,以及勾上实时同步
2.在线打包时勾上uexLog插件。注意,这个插件只在项目没上线时用着,正式发布时,要把这个插件去掉。
3.写个日志输出方法(uexLog这插件只支持文本输出)
Date.prototype.Format = function(str) {
var o = {
"M+" : this.getMonth() + 1, //月份
"d+" : this.getDate(), //日
"h+" : this.getHours(), //小时
"m+" : this.getMinutes(), //分
"s+" : this.getSeconds(), //秒
"q+" : Math.floor((this.getMonth() + 3) / 3), //季度
"S" : this.getMilliseconds() //毫秒
};
if (/(y+)/.test(str))
str= str.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(str))
str= str.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return str;
};
var isLogEnable = true; //日志输出开关
function Logs(str) {
if (isLogEnable) {
var dateStr = (new Date().Format("yyyy-MM-dd hh:mm:ss"));
str = dateStr + " " + uexWidgetOne.platformName + "-->" + str;
if (uexLog) {
appcan.logs(str);
} else {
console.log(str);
}
}
}
4.最后要启动一下APPCAN调试中心服务。
PS:注意电脑防火墙,,有可能导致日志无法发送。。建议,调试时关闭防火墙
最近访客
全部评论
北堂棣 2017/03/14 15:18
http://newdocx.appcan.cn/dev-guide/use-chrome-debug-app 现在可以使用Chrome调试AppCan应用啦