HarmonyOS 实况窗出现一个问题,创建一个time类型的胶囊,报错:Start LiveView failed, msg=Parameter error. The type of capsule.title mustbe string \[or the parameter is mandatory\].?

如题:HarmonyOS 实况窗出现一个问题,创建一个time类型的胶囊,报错:Start LiveView failed, msg=Parameter error. The type of capsule.title mustbe string [or the parameter is mandatory].?

阅读 564
1 个回答

实况窗出现一个问题,创建一个time类型的胶囊,报错:

Start LiveView failed, msg=Parameter error. The type of capsule.title mustbe string [or the parameter is mandatory]. 

代码如下:

let capsuleData: liveViewManager.TimerCapsule = {
  type: liveViewManager.CapsuleType.CAPSULE_TYPE_TEXT,
  status: 1,
  icon: "capsule_store.png", // 胶囊图标,取值为“/resources/rawfile”路径下的文件名
  backgroundColor: "#ff0959F8",
  content: "时间胶囊",
  time: 15
}

但是TimerCapsule这个东西里面没有title:

export interface TimerCapsule extends CapsuleData {
  /**
   * the content of capsule content of liveView.
   *
   * @type { ?string }
   * @syscap SystemCapability.LiveView.LiveViewService
   * @StageModelOnly
   * @since 4.1.0(11)
   */
  content?: string;
  /**
   * the time of capsule content of liveView.
   *
   * @type { ?number }
   * @syscap SystemCapability.LiveView.LiveViewService
   * @StageModelOnly
   * @since 4.1.0(11)
   */
  time?: number;
  /**
   * Indicates whether the capsule of the timer type is countdown,The default value is false.
   *
   * @type { ?boolean }
   * @syscap SystemCapability.LiveView.LiveViewService
   * @StageModelOnly
   * @since 4.1.0(11)
   */
  isCountdown?: boolean;
  /**
   * Indicates whether the capsule of the timer type pauses timing. The default value is false.
   *
   * @type { ?boolean }
   * @syscap SystemCapability.LiveView.LiveViewService
   * @StageModelOnly
   * @since 4.1.0(11)
   */
  isPaused?: boolean;
}

time胶囊类型应该使用CAPSULE\_TYPE\_TIMER。

参考链接:https://developer.huawei.com/consumer/cn/doc/harmonyos-references-V5/liveveiw-liveviewmanager-V5\#section136243383011

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进