这里的通信主要测试环境是打包APP
端和web-view
内嵌网页的双向通信。
一、 内嵌网页向uni-app
通信
参考文章:uniapp web-view
- 内嵌网页向
uni-app
发消息
在web-view
访问的网页内引入uni.webview.1.5.3.js
,待sdk
加载完毕后就可以调用方法postMessage
。如下:
// index.html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script type="text/javascript" src="https://gitee.com/dcloud