0
所以我見過車把模板做到這一點:使用腳本標記爲JavaScript模板,而不是字符串
<script id="some-template" type="text/x-handlebars-template"> </script>
,我想知道是否有使用underscore.js模板這樣的方式。將模板放在標記中而不是坐在一個字符串中會非常好。
所以我見過車把模板做到這一點:使用腳本標記爲JavaScript模板,而不是字符串
<script id="some-template" type="text/x-handlebars-template"> </script>
,我想知道是否有使用underscore.js模板這樣的方式。將模板放在標記中而不是坐在一個字符串中會非常好。
當然,你可以輕鬆地做到這一點。
var templateText= document.getElementById('some-template').innerHTML;
爲什麼不只是使用把手? (注意:我喜歡把手。) – Mathletics
對於任何你想要的東西,你都可以使用該腳本標籤技巧。 – Pointy
@點關心詳細點? – thatmiddleway