0
我在格式化Websql的ClojureScript包裝時遇到了一些麻煩。主要的問題是JavaScript使用websql的tx和err參數,這些參數沒有被定義。當ClojureScript版本運行時,代碼會拋出錯誤,因爲tx未定義。下面是一些示例代碼與一個websql tutorial from PhoneGap跟着我嘗試:ClojureScript中的WebSQL?
(defn populateDB [tx]
(.executeSql tx ("CREATE TABLE IF NOT EXISTS foo (id unique, text)"))
(.log js/console "table added"))
(defn errorCB [err]
(.log js/console (str "There was an error" (.code err))))
(defn successCB []
(.alert js/window "It worked!"))
;; Run the transactions
(def db
(.openDatabase js/window "Database" "1.0" "Cordova Demo" 1024))
(.transaction db (populateDB) (errorCB) (successCB))
有沒有什麼辦法讓這個工作,或者已經存在的WebSQL + ClojureScript任何庫?