gpt4 book ai didi

riot.js - 如何更新防暴标签的属性?

转载 作者:行者123 更新时间:2023-12-02 04:29:15 25 4
gpt4 key购买 nike

我创建了一个 riot 标签,它在循环中呈现许多 svg 元素

<circle ref={ keyName } each={ point,keyName in opts.points } ></circle>

现在我有两个条件

  1. 更新特定标签
  2. 更新所有标签

要更新特定标签的属性,我使用 this.refs[ someName ].setAttributes("cx", 30);

要更新所有标签的属性,我应该在循环中使用上述方法吗?或者我应该更新 opts.points 并调用 this.update()

最佳答案

您只需要更新您的列表 opts.points,riot.js 将更改 html,而无需您在评论时使用 jQuery 引用每个项目。

检查 opts.lists 是否正在更新,这可能是你的问题,但你可以通过以下方式解决此问题:

 <circle ref={ keyName } each={ point,keyName in this.points } ></circle>
<script>
this.points = opts.points // the parent component is providing a list

someFunction() {
this.points = ["something", "whatever", "another thing"]
this.update()
}
</script>

关于riot.js - 如何更新防暴标签的属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50567617/

25 4 0