UTS运行到鸿蒙报如下错误:
Cannot read property observeComponentCreation2 of undefined
index.uts代码如下:
import { AddFun } from '../interface.uts'
import { button } from "./button.ets"
export const addFun : AddFun = function () : void {
button.ChangeArkts()
}
button.ets代码如下
import { MainPage } from 'library'
import { UIContext, ComponentContent } from '@kit.ArkUI';
@Entry
@Component
struct ButtonComponent {
build() {
Row() {
// 引用HAR的ArkUI组件
MainPage()
}
.height('100%')
}
}
@Builder
function RegisterBuilder() {
ButtonComponent()
}
export class button {
static ChangeArkts() {
RegisterBuilder()
// wrapBuilder(RegisterBuilder)
}
}
赢无翳 (作者)
附件已上传,可运行测试项目请下载附件,harmony-configs目录配置请把compatibleSdkVersion的API改为5.0.5(17)
2025-09-02 11:00
DCloud_UNI_yuhe
回复 赢无翳: 行,等我看一下的
2025-09-02 11:03
DCloud_UNI_yuhe
你提供的项目中,删除了很多引用的内容,导致无法运行,请你修改一下附件到可以正常运行
11:08:31.545 正在编译中...
11:08:33.591 [plugin:uts] Cannot find module '/Users/gaoruicheng/Downloads/hmtest/uni_modules/ux-frame' from '/Users/gaoruicheng/Downloads/hmtest/main.uts'
11:09:06.171 开始差量编译...
11:09:07.295 [plugin:uts] Cannot find module '/Users/gaoruicheng/Downloads/hmtest/uni_modules/fz-savefile' from '/Users/gaoruicheng/Downloads/hmtest/pages/videosy/videosy.uvue?vue&type=script&lang.uts'
2025-09-02 11:10