H5调用安卓和iOS方法通过js

2022-07-04  本文已影响0人  笨的很想飞
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>发送咨询单</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <!--    引入vant-->

</head>

<body>
    <div style=" background-color: #f4f4f4;">
        <h2 onclick="onCancel()">测试</h2>
    </div>
</body>

</html>
<script>
    function onCancel() {
        console.log(123)
        if (window.webkit != undefined) {
<!--            方法名 --  -(void)back{}>
            window.webkit.messageHandlers.back.postMessage('');

        } else {
            /* eslint-disable */
            android.backHome();
        }
    };
</script>


上一篇 下一篇

猜你喜欢

热点阅读