我不断收到 Handlebars.compile() 调用的 TypeError 错误。我尝试按照其他帖子中的建议将 jQuery.noConflict() 添加到各个位置,但运气不佳。
TypeError: 'undefined' is not a function (evaluating 'Handlebars.compile('test')')
代码是:
$('.location-typeahead').typeahead(
{
name: 'states',
displayKey: 'value',
source: states(),
templates: {
header: '<h4 class="location-typeahead-header">Title</h4>',
suggestion: Handlebars.compile('test')
}
}
);
如果我删除整个“建议”模板参数,我的 JS 就可以正常工作。
最佳答案
您可能已经包含了 Handlebars 的运行时版本。如果您想在客户端编译模板,则需要包含完整版本。
或者,您可以预编译模板 - 那么您只需要运行时。
关于javascript - 类型错误 : 'undefined' is not a function even when using jQuery. 无冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21842336/