spa*_*kle 5 javascript jquery backbone.js underscore.js
如果我在Chrome JS控制台上键入"_.template($('#pranks-list').html())"它也能正常工作
>> _.template($('#pranks-list').html())
function (a){return e.call(this,a,b)}
Run Code Online (Sandbox Code Playgroud)
app.js //观点
window.PranksListView = Backbone.View.extend({
template: _.template($('#pranks-list').html())
});
Run Code Online (Sandbox Code Playgroud)
的index.html
<script type="text/html" id="pranks-list">
<li><a href='#pranks/<%= id %>'><%= name %></a></li>
</script>
</body>
Run Code Online (Sandbox Code Playgroud)
为什么我在这行上出现这个错误?
template: _.template($('#pranks-list').html())
Run Code Online (Sandbox Code Playgroud)
u.k*_*u.k 15
没有看到整个代码就很难分辨,但是你可能_.template($('#pranks-list').html())
在创建dom之前尝试运行并且节点在那里.通常,在准备好模板变量时,在渲染时渲染模板是一种很好的做法:
_.template($('#pranks-list').html(), {id: 'foo', name: 'bar'});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
19147 次 |
最近记录: |