這是我想出來的代碼:http://jsfiddle.net/sbrsK/10/
它正常運行沒有的jsfiddle爲什麼瀏覽器在使用handlebars.js時在Firefox中返回錯誤「TypeError:this._input爲null」(在Chrome中類似)?
任何錯誤試圖通過Web服務器在本地運行同樣在我的電腦不能正常工作。 下列文件被加載:
- 的index.html
- app.js
在Firefox我得到這個錯誤:
TypeError: this._input is null @ http://cloud.github.com/downloads/wycats/handlebars.js/handlebars-1.0.0.beta.6.js:364
在Chrome我得到這個錯誤:
Uncaught TypeError:Cannot call method 'match' of null
under match = this._input.match(this.rules[rules[i]]); in handlebars-1.0.0.beta.6.js
這個link之前有一個非常類似的問題,但似乎它仍然是開放的。
所以問題是爲什麼這個錯誤發生時,它在jsfiddle中正常工作? 什麼是在本地運行的正確方法?
謝謝你的指導@ mu-is-too-short請檢查我的答案,並讓我知道這是你的意思。此外,呈現的頁面無法正確顯示。任何原因爲什麼? [index.html](http://pastebin.com/tKNGCSyA); [app.js](http://pastebin.com/BGPcz71w); [輸出](http://pastebin.com/5uH25H1B) – boiledice
I從[here](http://icanhazjs.com/)獲得了一些額外的幫助 – boiledice
我修正了我的app.js,我刪除了console.log,輸出現在如預期的那樣。 – boiledice