52yaoer
52yaoer
  • 发布:2025-11-04 09:46
  • 更新:2025-11-04 16:02
  • 阅读:36

uts开发鸿蒙自定义原生View组件,第一次正常运行。第二次就崩溃了

分类:uts

第一次正常运行。

第二次出现错误

this.builder = element.bindHarmonyWrappedBuilder(wrapBuilder<[NativeSVGAPlayerOptions]>(buildButton), this.params)

出现以下错误

 {name: "Error", message: "uiContext is not null", stack: "    at uiContext (oh_modules/.ohpm/@tb-open+svga@1.3.6/oh_modules/@tb-open/svga/src/main/ets/player/index.ets:182:13)\n    at aboutToAppear (oh_modules/.ohpm/@tb-open+svga@1.3.6/oh_modules/@tb-open/svga/src/main/ets/componentsV2/index.ets:38:5)\n    at buildWithNestingBuilder (../../../foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/jsXNode.js:203:1)\n    at build (../../../foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/jsXNode.js:212:1)\n    at build (../../../foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/jsXNode.js:70:1)\n    at bindHarmonyWrappedBuilder (oh_modules/.ohpm/@dcloudio+uni-app-x-runtime@hqgpwjvfrybdsrzarkopqsjgek8wioasijtg8u8xz1w=/oh_modules/@dcloudio/uni-app-x-runtime/src/main/ets/runtime/dom/UniNativeViewElement.ets:94:17)\n    at bindView (uni_modules/XF-SVGAPlayerUTS/utssdk/app-harmony/index.ets:45:32)\n    at anonymous (uni_modules/XF-SVGAPlayerUTS/utssdk/app-harmony/index.ets:22:18)\n"}
2025-11-04 09:46 负责人:无 分享
已邀请:
DCloud_UNI_OttoJi

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

提供具体复现工程,第二次出现错误是调试模式热重载有问题,还是退出页面再进来有问题。如果你认为是 bug,请编辑此问题,使用 bug 分类模板进行反馈,说明 HBuilderX 版本、vue 版本、是 uniapp 还是 uniappx,并提供复现工程说明操作步骤。

52yaoer

52yaoer (作者)

解决了,

  • DCloud_UNI_OttoJi

    提供下问题原因和解决思路把,方便其他人参考和解决问题

    2025-11-04 15:24

52yaoer

52yaoer (作者)

@Builder  
export function buildButton(params: ESObject) {  
    SvgaPlayerV2({  
      url: params.path,  
      controller: params.controller  
    })  
}

以上代码的controller我是写咯一个ets导入的。其他地方公用。
第二次执行这个Builder没有重新生成这个controller,导致的。

要回复问题请先登录注册