预览告警“@Consume/@Link decorated property <propertyName> not initialized”
======================================================================

**问题现象**

启动预览后，预览窗口显示白屏，上方出现错误信息：“Preview failed. View details in the PreviewerLog window.”

![](https://contentcenter-vali-drcn.dbankcdn.cn/pvt_2/DeveloperAlliance_scene_100_1/df/v3/4Tw9f6_TT0GIRJ5lsyQ9TQ/zh-cn_image_0000002194317968.png?HW-CC-KV=V1&HW-CC-Date=20260612T074805Z&HW-CC-Expire=86400&HW-CC-Sign=D4582752344562B13DB3082D4AC6D8F466071F27C8B8899EB57636FA106BB8A0 "点击放大")

此时，PreviewerLog 窗口显示如下告警信息：“@Consume/@Link 装饰的属性 \_<propertyName>\_未初始化。”

![](https://contentcenter-vali-drcn.dbankcdn.cn/pvt_2/DeveloperAlliance_scene_100_1/c6/v3/umqsEJa0RKOlfC8NGd61Pg/zh-cn_image_0000002194158348.png?HW-CC-KV=V1&HW-CC-Date=20260612T074805Z&HW-CC-Expire=86400&HW-CC-Sign=1EC8A2CDC6DB1E06287F97DB78AFB0470E9DC7C234519E3E013B3115CA5DD0E3)

**解决措施**

由于@Consume/@Link装饰的成员需要与父组件建立绑定关系，单独预览时无法完成初始化，因此如果预览包含@Consume（或@Link）装饰的成员的页面或组件，就可能会出现空白屏幕。

建议不要直接预览含有@Consume或@Link装饰的子组件，而应通过预览父组件来查看子组件的预览效果。

示例代码：

// Suggest adding @ Preview on ParentComp to preview the preview effect of ChildComp
@Preview
@Component
struct ParentComp {
  // @Provide decoration is provided by the entrance component ParentComp as its descendant component
  @Provide reviewVotes: number = 10;

  build() {
    Column() {
      Button(\`reviewVotes(${this.reviewVotes}), give +1\`)
        .onClick(() => this.reviewVotes += 1)
      ChildComp()
    }
  }
}

// @Preview is not recommended to directly preview ChildComp
@Component
struct ChildComp {
  // The variable decorated with '@Consume' is bound to the variable decorated with '@Provide' in its ancestor component ParentComp using the same attribute name
  @Consume reviewVotes: number;
  build() {
    Column() {
      Text(\`reviewVotes(${this.reviewVotes})\`)
      Button(\`reviewVotes(${this.reviewVotes}), give +1\`)
        .onClick(() => this.reviewVotes += 1)
    }
    .width('50%')
  }
}