gpt4 book ai didi

polymer - polymer 中的 hostAttributes 和 properties 有什么区别?

转载 作者:行者123 更新时间:2023-12-04 04:21:21 24 4
gpt4 key购买 nike

我正在从 0.5 迁移到 1.0。

在阅读时,我注意到声明属性的两种不同方式,使用 hostAttributesproperties .

那 2 有什么区别?

最佳答案

主机属性是与元素的相应 Javascript 属性(您在 properties 中声明的属性)不匹配的属性。这包括像 class 这样的属性。 , tabindex , data-*属性、aria-roles 等。要在创建时声明它们,您必须在 hostAttributes 中设置它们。目的。如果要将值绑定(bind)到其中,则必须使用 $= (调用 Element.setAttribute )而不是 = .

资料来源:

  • https://www.polymer-project.org/1.0/docs/devguide/registering-elements.html#host-attributes
  • https://www.polymer-project.org/1.0/docs/devguide/data-binding.html#attribute-binding
  • 关于polymer - polymer 中的 hostAttributes 和 properties 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30723418/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com