js判断是否在微信小程序webview中,而不是微信网页 var u = navigator.userAgent; if(u.indexOf("miniProgram") != -1){ //在微信小程序 }else { //在微信网页 }