MENU

传值

h5与uniapp之间通过webview通信

引入

<!-- 引入 uniapp webview sdk 在body后 -->
<script src="https://js.cdn.aliyun.dcloud.net.cn/dev/uni-app/uni.webview.1.5.2.js"></script>

网页向 APP 传值

function postMsg() {
    uni.getEnv(function (res) {
      console.log('shebei' + JSON.stringify(res))
    })
    // 向 APP 发送消息 (注意看这里 01)
    uni.postMessage({
      data: {
        name: 'head',
        age: 19,
        appfv:true
      }
    })

APP 接受传值

<template>
    <view class="content"><web-view src="http://" @message="handleMessage"></web-view></view>
</template>

<script setup>


function handleMessage(evt) {
    const [data] = evt.detail.data
}


</script>

APP 向网页传值

就是链接里加了个参数

Read More