1.H5向APP界面跳转

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
goTo() {
const u = navigator.userAgent;
const isAndroid = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1; //android终端
const isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
if (isAndroid) {
window.toWebView.toWebView("5", this.userId);
}
if (isiOS) {
const post = {
type: "5",
userId: this.userId
};
window.webkit.messageHandlers.toWebView.postMessage(
JSON.stringify(post)
);
}
}

Notice: (1) 如果是Android界面,需要加window;(2)如果是IOS,需要一个字段传输string的话,需先定义一个对象,然后用JSON.stringify格式化成一个字符串

2.APP端向H5端跳转(通过链接传参)

在APP向H5传递参数的时候,要用”/“进行拼接,拼接的顺序按照参数出现的顺序进行拼接。

3.h5页面滑动不流畅的问题

在滚动的容器中增加:-webkit-overflow-scrolling : touch;

需要滑动的是哪块区域,就在哪里加上这段代码就OK。