问题:系统崩溃信息不知道啥原因

背景:跑api10的 hello world的demo,采用自动签名,结果在会报错

 

崩溃信息:

Device info:0penHarmony 3.2
Build info:0penHarmony 4.0.9.6
Module name:com.demo.myapplication

Version:1.0.0
Pid:3641

Uid:20010041
Lifetime: 0.000000s
Js-Engine: ark
page: pages/Index.js
Error message:is not callable
SourceCode:
this.observeComponentCreation2((elmtId,isInitialRender)=>{
Stacktrace:
at initialRender (entry/src/main/ets/pages/Index.ets:11:3)

 

 

 

代码:

// Index.ets
// 导入页面路由模块
import router from '@ohos.router';
import { BusinessError } from '@ohos.base';

@Entry
@Component
struct Index {
  @State message: string = 'Hello World';

  build() {
    Row() {
      Column() {
        Text(this.message)
          .fontSize(50)
          .fontWeight(FontWeight.Bold)
        // 添加按钮,以响应用户点击
        Button() {
          Text('Next')
            .fontSize(30)
            .fontWeight(FontWeight.Bold)
        }
        .type(ButtonType.Capsule)
        .margin({
          top: 20
        })
        .backgroundColor('#0D9FFB')
        .width('40%')
        .height('5%')
        // 跳转按钮绑定onClick事件,点击时跳转到第二页
        .onClick(() => {
          console.info(`Succeeded in clicking the 'Next' button.`)
          // 跳转到第二页
          router.pushUrl({ url: 'pages/Second' }).then(() => {
            console.info('Succeeded in jumping to the second page.')
          }).catch((err: BusinessError) => {
            console.error(`Failed to jump to the second page.Code is ${err.code}, message is ${err.message}`)
          })
        })
      }
      .width('100%')
    }
    .height('100%')
  }
}

 

Logo

社区规范:仅讨论OpenHarmony相关问题。

更多推荐