var ua = navigator.userAgent.toLowerCase(); if(ua.indexOf("miniprogram") != -1){ //小程序; }else{ //不是小程序; }