Vue与IOS、andriod、微信交互的方法

一、IOS、Android调用Vue.js

1.在【Method】中定义一个方法

scanResult(result){
      this.language=result;
},

2.在【create】中把该方法定义为全局方法

window.scanResult=this.scanResult;

3.IOS、Android直接调用该方法就可以了

二、Vue.js判断微信、IOS、Andriod

        var ua = window.navigator.userAgent.toLowerCase();
        if (ua.match(/MicroMessenger/i) == 'micromessenger') {//在微信中打开
          this.$router.push({path: '/componentTwo/'+index
           });
          window.scollTop=0;
        }
        var u = navigator.userAgent;
        if(u.indexOf('Android') > -1 || u.indexOf('Adr') > -1){ //android终端
          Android.startActivity('http://139.196.20.27:8882/dist/#/componentTwo/'+index,title);
        }
        else if(!!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)){ //ios终端
          app.toArticleTitle('http://139.196.20.27:8882/dist/#/componentTwo/'+index,title);
        }else{

        }

猜你喜欢

转载自blog.csdn.net/weixin_43837268/article/details/84746415