假设我有以下 html:
<div class="item">one</div>
<div class="item">two</div>
<div class="item">three</div>
我想记录每个元素的 innerHTML。我尝试了以下方法:
document
|> Document.querySelectorAll(".item")
|> NodeList.toArray /* not sure if this is needed */
|> Array.map(Document.ofNode) /* not sure if this is needed */
|> Array.map(Element.innerHTML)
|> Array.iter((number) => {
Js.log(number);
});
错误在线|> Array.map(Element.innerHTML)
错误是:
This has type:
array(Webapi.Dom.Element.t) => array(string)
But somewhere wanted:
array(Dom.node) => 'a
我怎样才能使用Dom.node
以便我访问innerHTML
?