我让这个代码片段使用JavaScript在浏览器上工作:
Array.from(document.querySelectorAll('input'))document.querySelectorAll('input')获得一个NodeList,Array.from将其转换为一个数组。
我试图将其转换为函数中的Parenscript,如下所示:
(ps:chain array (from (ps:chain document (query-selector "input")))))这是非常接近的:
"array.from(document.querySelector('input'));"甚至还有一个用-array连字符来实现大写字母的小技巧。
(ps:ps (ps:chain -array (from (ps:chain document (query-selector "input")))))它产生:
"Array.from(document.querySelector('input'));"但是,当调用时,它不像预期的那样工作。它返回一个空字符串。
我怎么才能修好它?
我正在使用通用Lisp/SBCL。
发布于 2021-07-30 21:17:39
当前,Parenscript只返回以下原语值:
代码document.getElementsByTagName('input')不是返回字符串,而是返回一些对象。这就是它不能工作的原因。
来源。
https://stackoverflow.com/questions/68597182
复制相似问题