Some interfaces, such as service.share, are not supported overseas. How to check and shield them in the code without affecting the use of the domestic version?

Solutions:

To determine the current fast application center huawei account countryCode (details of how to obtain: developer.huawei.com/consumer/cn… :

The app.ux code snippet is as follows:

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
    }
Copy the code

Call service.share in ux:

FastAppShare () {if (this. $app. $def. Test () = = = 'CN') {share. Share ({/ / here for three sides share content})}}Copy the code

The original link: developer.huawei.com/consumer/cn…

Original author: Mayism