let shareSelect = (ev :any) => { const u :any= navigator.userAgent; const win :any = window const windowsAndroid :any = win.android const windowsWebkit :any = win.webkit const isAndroid:any = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android安卓 const isiOS :any= !!u.match(/(i[^;]+;( U;)? CPU.+Mac OS X/); //ios苹果 if (isAndroid) { let obj:any = { image:state.shareImage, title:state.shopInfo.shopName, description:state.shopInfo.address, } let params:any = JSON.stringify(obj) try { windowsAndroid.shareLinkContentToSession(params)//shareLinkContentToSession 为安卓定义的方法 } catch (e) { console.log(e) } } else if (isiOS) { let obj:any = { image:state.shareImage, title:state.shopInfo.shopName, description:state.shopInfo.address } let params :any= JSON.stringify(obj) try { windowsWebkit.messageHandlers.shareLinkContentToSession.postMessage(params)//shareLinkContentToSession 为ios定义的方法 } catch (e) { console.log(e) } } }