1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
- <title>web-view</title>
-
- <style>
- html,
- body,
- .map {
- width: 100px;
- height: 100px;
- }
- </style>
- </head>
- <body>
- <div class="map" tabindex="0">
- <button class="btn btn-red" type="button" data-action="switchTab">switchTab</button>
- </div>
-
-
- <!-- 微信 JS-SDK 如果不需要兼容小程序,则无需引用此 JS 文件 -->
- <!-- <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script> -->
- <!--uni SDK 一定要引入 -->
- <script type="text/javascript" src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js">
- </script>
- <script type="text/javascript">
- // 在引用依赖的文件后,需要在 HTML 中监听 UniAppJSBridgeReady 事件触发后,才能安全调用 uni 的 API。
- document.addEventListener('UniAppJSBridgeReady', function() {
- console.log("11111111111");
- document.querySelector('.map').addEventListener('click', function(evt) {
- console.log("2222222");
- var target = evt.target;
- if (target.tagName === 'BUTTON') {
- var action = target.getAttribute('data-action');
- if (action === 'switchTab') {
-
- uni.webView.navigateTo({
- url: '/pages/info/add?id=1'
- });
- }
- }
- });
- });
- </script>
- </body>
- </html>
|