首页 > 解决方案 > Aframe 按组件选择

问题描述

有没有办法选择所有附有特定组件的实体?

我正在尝试document.querySelectorAll(".shadow");和其他各种组合都无济于事。

标签: javascripthtmlaframe

解决方案


I believe you're looking for a attribute selector - which allows grabbing HTML nodes by their attributes. a-frame components are pretty much custom made HTML attributes - you're setting them using setAttribute() :)

In your case it would be document.querySelectorAll("[shadow]")

Check it out in this fiddle.


推荐阅读