-1

我在用着[cljsjs/localforage "1.2.10-0"]

当我做:

(.setItem (.localforage js/window) "mynumber" (clj->js {:number (.-value number)}))

我在 WebIDE 控制台中收到此错误:

 TypeError: *TypeError: window.localforage is not a function*

如果我在 Firefox 浏览器中测试它,它会说同样的话,而如果我在控制台中引入window.localforage.setItem()它,它可以工作:|

奖励:每次我用 lein cljsbuild auto 编译时,我都会得到这个:

*Upstream deps.cljs found on classpath. {:foreign-libs [{
  :file "cljsjs/localforage/development/localforage.inc.js", 
  :provides ["cljsjs.localforage"], 
  :file-min "cljsjs/localforage/production/localforage.min.inc.js"
}], 
:externs ["cljsjs/localForage/common/localforage.ext.js"]}
This is an EXPERIMENTAL FEATURE and is not guarenteed to remain 
stable in future versions.* 
4

1 回答 1

1

好吧,似乎正确的调用方式是(.-localforage js/window)[注意破折号]

(.setItem (.-localforage js/window) "mynumber" (clj->js {:number (.-value number)}))

到目前为止一切顺利:D

于 2015-10-23T08:35:00.730 回答