Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 Clojurescript Om,我需要访问组件中包含的其中一个 DIV 上的底层 DOM 元素(以便我可以将 offsetTop 设置为 0)。我怎样才能访问这个元素?
您可以使用get-node. 这里有一个例子。
get-node
请注意,组件必须已经安装才能访问其 DOM 元素,因此您应该调用get-node在组件安装后调用的 Om 生命周期方法之一(例如did-mount)。
did-mount
如果您使用的是 om.next,那么您应该使用该node函数。
node