在网络组件中不使用保留 public 名称的正确方法是什么

What is the right way to not use reserved public name withing web-component

当我 运行 使用模板构建时,我得到

[Warn]
The @Prop() name "title" is a reserved public name. Please rename the "title"
 prop so it does not conflict with an existing standardized prototype member.
 Reusing prop names that are already defined on the element's prototype may
 cause unexpected runtime errors or user-interface issues on various browsers,
 so it's best to avoid them entirely.

我知道这只是一个警告,但由于它可能会导致意外的 运行时间错误,我想知道是否已经存在一些命名标准。 (因为 title 对我来说是更明显的专有名称)。
如果不是,最佳做法是什么?

title 是全局 html 属性名称 - 'reserved'。参见 https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes。作为最佳实践,您不应为 @Props 使用全局属性名称。我不知道有什么 'standard' 可以命名 属性,它是组件的标题,但与全局标题属性(通常用于工具提示)不同。

截至今天,我发现的唯一解决方法是将 attributes 添加为 属性 并通过此变量传递所有信息,如下所示

attributes: {
  title: string
  description: string
  /** ... */
}

没有比这更好的了。
但我仍然愿意接受任何想法

Properties 和 component attributes 有很强的联系,但不一定是一回事。 由于 HTMLElement 属性类型,我们不能使用 title 变量,但我们可以像这样将字段文本设置为标题

@Prop({ attribute: 'title' }) heading?: string;