封装
// 方法封装
export function webviewNavigate(navFunc, ...navParams) {
// If the current page is in a webview, postMessage to parent window to navigate
// Otherwise, navigate directly
console.log(navFunc, ...navParams);
const platform = uni.getSystemInfoSync().uniPlatform;
if (platform === 'web' && window.location.href.match(/webView=true/)) {
uni.webView[navFunc](...navParams);
} else {
uni[navFunc](...navParams);
}
}
实现
webviewNavigate('navigateTo', {
url: "webview?id=" + data.id + "&token=" + token + "&parkId=" + parkId
});