预览告警“@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/cd/v3/LyyyIRDESGu3VLOsPWPLZA/zh-cn_image_0000002654797821.png?HW-CC-KV=V1&HW-CC-Date=20260709T134347Z&HW-CC-Expire=86400&HW-CC-Sign=F9C8ADB8184439628816144EE0349B0557EC9666BD573B7C7B2DDCBEF422469C "点击放大")

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

![](https://contentcenter-vali-drcn.dbankcdn.cn/pvt_2/DeveloperAlliance_scene_100_1/35/v3/RsmQKXtZTnOQYsQLN8wucg/zh-cn_image_0000002624638362.png?HW-CC-KV=V1&HW-CC-Date=20260709T134347Z&HW-CC-Expire=86400&HW-CC-Sign=65A095BD5D5D760349A6E074A6500D5019177C73CF7CE9A64A136D32662DB115)

**解决措施**

由于@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%')
  }
}