zoukankan      html  css  js  c++  java
  • js调起android安卓与ios苹果方法 vue3.0 + ts

    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) 
        } 
      }
    }
  • 相关阅读:
    poj 2386 Lake Counting
    hdu 3998 Sequence
    hdu 1556 Color the ball
    synchronized和ReentrantLock的区别
    4种常用线程池
    java深浅拷贝
    ConcurrentHashMap总结
    List原理
    volatile关键字
    java关键字总结
  • 原文地址:https://www.cnblogs.com/lnzixin/p/15308771.html
Copyright © 2011-2022 走看看