教你使用一套代码解决出海问题
文章目录
快应用海外不支持一些接口,比如 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
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论