关于android:教你使用一套代码解决出海问题

快利用海内不反对一些接口,比方 service.share ,怎么在代码里判断并屏蔽,又不影响国内版本的应用呢?

解决办法:

能够先判断下以后快利用核心华为帐号的countryCode(如何获取详见:https://developer.huawei.com/…

app.ux代码片段如下:

data: {
      localeObject: ''
    },
    test() {
      device.getServiceCountryCode({
        success: function (ret) {
          this.localeObject = ret.serviceCountryCode
          console.log(ret.serviceCountryCode);
        },
        fail: function (erromsg, errocode) {
          this.localeObject = 'errocode:' + errocode + ',erromsg:' + erromsg
          console.log(erromsg, errocode);
        },
        complete: function () {
        }
      })
      return this.localeObject
    }

页面ux中调用service.share:

fastAppShare() {
      if (this.$app.$def.test()==='CN') {
        share.share({
          //此处为三方分享内容
        })
      }
    }

原文链接:https://developer.huawei.com/…
原作者:Mayism

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理