H5代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Expires" content="0">
<title>Title</title>
<link href="test.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="btn" onclick="toWxa('test-------1111')">传参 'test-------1111'</div>
<div class="btn" onclick="toWxa({key:'value'})">传参 {key:'value'}</div>
<script src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
<script>
function toWxa (param) {
wx.miniProgram.postMessage ({
data: param,
})
wx.miniProgram.navigateBack ();
}
</script>
</body>
</html>
css
.btn{
width: 100%;
text-align: center;
height: 50px;
background: #0c80fe;
border-radius: 5px;
line-height: 50px;
color: white;
}
传递不同参数小程序端收到的打印结果
postMessage为字符串打印结果
postMessage为Map对象打印结果
微信下打开是正常的,iOS下也是正常的,只有安卓手机的企微打开会有这个问题
你好,这个是已知问题,会在下版本修复,目前可以使用json