function onLine(callback){
var img = new Image();
img.src = 'https://www.baidu.com/favicon.ico';
img.onload=function(){
if (callback) callback(true)
};
img.onerror=function(){
if (callback) callback(false)
};
}
onLine(function(flag){
if(flag){
console.log('网络畅通')
}else{
console.log('网络故障')
}
})