关于在 ClojureScript 当中引入依赖 document 对象的包(笔记)
一般前端代码崔主要是为了在浏览器环境运行, if (typeof window != undefined) { // do something } 如果是 ClojureScript 当中遇到此类的代码,也类似: (if (exists? js/window) (comment "do soemthing")) 问题这一次是我引用了一个 https://alertifyjs.org/ 的模块, ReferenceError: document is not defined 如果是 js,我在 (ns app.main (:require ["alertify.js" :as alertify])) 至少在我没搞清楚 解决方案于是我想到说用 shadow-cljs 对 js 模块做重定向的功能的做法, :page {:target :node-script :output-to "target/page.js" :js-options {:resolve {"alertify.js" {:target :file :file "entry/alert-ssr.js"}}} :main app.page/main! :devtools {:after-load app.page/main!}}}}
不过实际使用遇到的问题,问了作者,他在 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |