我正在尝试将一个JavaScript对象转换为Clojure。但是,我遇到了以下错误:
(js/console.log (js->clj e)) ;; has no effect
(pprint (js->clj e)) ;; No protocol method IWriter.-write defined for type object: [object Geoposition]
是的,这个对象来自于Geolocation API。我想我需要扩展IEncodeClojure
和IWriter
,但我不知道该怎么做。
例如,添加以下内容:
(extend-protocol IEncodeClojure
Coordinates
(-js->clj [x options]
(println "HERE " x options)))
加载我的代码时会产生错误:Uncaught TypeError: Cannot read property 'prototype' of undefined
undefined
吗?(js/console.log (undefined? e))
会产生什么结果? - Tim Pote(js/console.log e)
和(js/console.log (js->clj e))
时,我得到相同的js对象。 - nha