小编amh*_*hou的帖子

在Spine.js中传递this.item时,把手会断裂

我正在尝试实现Spine.js文档中给出的Todo示例,这里给出了:http://spinejs.com/docs/example_tasks

只有我想使用Handlebars而不是jQuery.tmpl.我正在使用Handlebars 1.0.rc.1

但是,当我试图打电话时:

template: Handlebars.compile($('#history-template').html()),

render: function(){
    var t = this.template(this.item);
    this.replace(t);
    return this;
}
Run Code Online (Sandbox Code Playgroud)

把手抛出异常this.template(this.item):

Uncaught TypeError: Cannot call method 'match' of undefined
Run Code Online (Sandbox Code Playgroud)

在Handlebars lexer中,this._input将以未定义的形式返回.

我的模板如下:

<script id='history-template' type='text/x-handlebars-template'>
    <div class="content-inner {{#if viewed}}msg_unseen{{/if}}">                                             
        <div>{{data}}</div>
    </div>
</script>
Run Code Online (Sandbox Code Playgroud)

数据:

"[{"data":"hello","id":"c-0"}]"
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

javascript spine.js handlebars.js

8
推荐指数
1
解决办法
424
查看次数

标签 统计

handlebars.js ×1

javascript ×1

spine.js ×1