方法名:pushToCustomer
/*
* vue访问原生安卓和IOS方法
* */
export function getDataFromNative(params) {
var u = navigator.userAgent, app = navigator.appVersion;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
if (isAndroid) {
android.pushToCustomer(params)
}
if (isiOS) {
window.webkit.messageHandlers.pushToCustomer.postMessage(params); // IOS
}
}
export default {
getDataFromNative,
};
网友评论