提交 c1d3e9c2 编写于 作者: 雪洛's avatar 雪洛

feat: web端暂不支持webview通讯

上级 35ecce45
...@@ -43,8 +43,13 @@ ...@@ -43,8 +43,13 @@
<!-- uni 的 SDK --> <!-- uni 的 SDK -->
<script type="text/javascript" src="uni.webview.1.5.5.js"></script> <script type="text/javascript" src="uni.webview.1.5.5.js"></script>
<script type="text/javascript"> <script type="text/javascript">
const isWeb = location.href && /^https?:/.test(location.href)
// document.addEventListener('UniAppJSBridgeReady', function() { // document.addEventListener('UniAppJSBridgeReady', function() {
document.querySelector('.btn-list').addEventListener('click', function(evt) { document.querySelector('.btn-list').addEventListener('click', function(evt) {
if(isWeb) {
alert('web端暂不支持此功能')
return
}
var target = evt.target; var target = evt.target;
if (target.tagName === 'BUTTON') { if (target.tagName === 'BUTTON') {
var action = target.getAttribute('data-action'); var action = target.getAttribute('data-action');
...@@ -82,6 +87,10 @@ ...@@ -82,6 +87,10 @@
}) })
// }); // });
document.querySelector("#postMessage").addEventListener('click', function() { document.querySelector("#postMessage").addEventListener('click', function() {
if(isWeb) {
alert('web端暂不支持此功能')
return
}
uni.webView.postMessage({ uni.webView.postMessage({
data: { data: {
action: 'message' action: 'message'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册