回不去的小时候
回不去的小时候
  • 发布:2025-08-13 10:31
  • 更新:2025-08-13 11:07
  • 阅读:26

开发鸿蒙应用时,使用uni.createWebviewContext('hm-webview', this);打印this.hmWebview为空对象

分类:鸿蒙Next

开发鸿蒙应用时,使用uni.createWebviewContext('hm-webview', this);打印this.hmWebview为空对象;
Hbuilderx版本4.56

2025-08-13 10:31 负责人:无 分享
已邀请:
DCloud_UNI_yuhe

DCloud_UNI_yuhe

this.hmWebview 指的是什么?

DCloud_UNI_OttoJi

DCloud_UNI_OttoJi - 日常回复 uni-app/x 问题,如果艾特我没看到,请主动私信

<template>  
  <view>  
    <button @click="goBack">go back</button>  
    <web-view style="height: 400px;width: 100%;" :fullscreen="false" id="webview1" src="https://baidu.com"></web-view>  

  </view>  
</template>  

<script>  
  let ctx  
  export default {  
    mounted() {  
      ctx = uni.createWebviewContext('webview1', this)  
    },  
    methods: {  
      goBack() {  

        ctx.back()  
      }  
    }  
  }  
</script>

参考这个,后面 hellouniapp 和文档会增加具体用法。

  • 回不去的小时候 (作者)

    您好,我这边场景是webview中的网页加载完之后,通过ctx.evalJS(document.body.className+=' mobile')改变网页的样式。但是现在问题是不知道网页什么时候能够加载完成,我不知道在什么时机执行ctx.evalJS(document.body.className+=' mobile')这行代码。

    2025-08-13 14:29

要回复问题请先登录注册