gpt4 book ai didi

css - 在 Angular2 中使用自定义 CSS 会出现 "Can' t bind since not native property“错误

转载 作者:太空宇宙 更新时间:2023-11-04 10:01:55 25 4
gpt4 key购买 nike

我的 CSS

ol.progress[data-steps="9"] li { width: 11%; }

我想像这样在我的模板中使用上面的内容:

<ol class="progress" data-steps=4>

<li *ngFor..> </li>

我试过了:

<ol class="progress" [data-steps]="myNg2Variable">

获取错误:

Template parse errors: Can't bind to 'data-steps' since it isn't a known native property

如何实现?

最佳答案

您需要将 attr 属性与插值一起使用:

<ol class="progress" attr.data-steps="{{myNg2Variable}}">

干杯

关于css - 在 Angular2 中使用自定义 CSS 会出现 "Can' t bind since not native property“错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38285550/

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