課程
/前端開發(fā)
/HTML/CSS
/Handlebars模板引擎
You must pass a string or Handlebars AST to Handlebars.compile. You passed undefined?什么錯誤啊求解
2018-01-15
源自:Handlebars模板引擎 3-3
正在回答
說錯莫怪哈~會不會是把渲染模塊的那段代碼寫在template前面了?以至于獲取不到template。
要么就把template寫在渲染模塊的那段代碼之前,像下面這樣2個script標(biāo)簽的順序。要么把渲染模塊的那段代碼用$(function({}))包起來。
<script id="template1" type="text/x-handlebars-template">
????<div>...<div>
</script>
<script>
????var t = $('#template1').html();
????var f = Handlebars.compile(t);
????var h = f(data);
舉報
使用Handlebars.js模板渲染頁面。
2 回答isfirst那個registerHelper里函數(shù)參數(shù)options是什么啊,為什么返回fn呢
1 回答#在這里的含義是什么?
1 回答分頁跳轉(zhuǎn)點擊錯誤
2 回答美滋滋,但是老師是怎么設(shè)置的跨域啊?后端設(shè)置嗎
1 回答老師,一樣的寫法,但是我的報錯了,顯示不出來,請問是什么原因
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2018-03-05
說錯莫怪哈~會不會是把渲染模塊的那段代碼寫在template前面了?以至于獲取不到template。
要么就把template寫在渲染模塊的那段代碼之前,像下面這樣2個script標(biāo)簽的順序。要么把渲染模塊的那段代碼用$(function({}))包起來。
<script id="template1" type="text/x-handlebars-template">
????<div>...<div>
</script>
<script>
????var t = $('#template1').html();
????var f = Handlebars.compile(t);
????var h = f(data);
</script>