当前位置:   article > 正文

uniapp h5端和react native 通信

uniapp h5端和react native 通信

1.react native 向uniapp h5传值时,直接通过url传值

  1. <script setup>
  2. const getUrlParams = () => {
  3. const url = window.location.href
  4. if (!url) return
  5. let urlStr = url.split('?')[1]
  6. let obj = {}
  7. let paramsArr = urlStr.split('&')
  8. for (let i = 0, len = paramsArr.length; i < len; i++) {
  9. let arr = paramsArr[i].split('=')
  10. obj[arr[0]] = arr[1]
  11. }
  12. console.log(obj )
  13. }
  14. getUrlParams()
  15. </script>

2.uniapp 向 react native传值

  1. window.ReactNativeWebView.postMessage(
  2. JSON.stringify(
  3. { type: "jumpOutsideWebView", data: 'url' })
  4. )

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/636994
推荐阅读
相关标签
  

闽ICP备14008679号