暂时没有办法,只能判断是否在app或者h5、获取小程序中预编译,或者js动态获取,可能后期 后支持。
// #ifdef APP-PLUS showClose:true //该代码仅在app中生效 // #endif // #ifdef H5 showClose:true //该代码仅在h5中生效 // #endif // #ifdef MP showClose:true //该代码仅在小程序中生效 // #endif // #ifdef MP-WEIXIN showClose:true //该代码仅在微信小程序中生效 // #endif // #ifdef MP-ALIPAY showClose:true //该代码仅在支付宝小程序中生效 // #endif // #ifdef MP-BAIDU showClose:true //该代码仅在百度小程序中生效 // #endif // #ifdef MP-TOUTIAO showClose:true //该代码仅在抖音、头条小程序中生效 // #endif //360、qq等小程序自己看图吧,就不意义列举了

js判断
let port = uni.getSystemInfoSync().platform switch (port) { case 'android': console.log('Android');//android break; case 'ios': console.log('iOS'); //ios break; default: console.log('小程序');//devtools break; }
网友回复