gpt4 book ai didi

templates - 升级到 underscore 1.7 时出现模板错误

转载 作者:行者123 更新时间:2023-12-02 23:06:06 24 4
gpt4 key购买 nike

将我的网络应用程序从下划线 1.6 升级到 1.7 时,我收到以下错误“列表未定义”。当使用下划线 1.6 时,它工作得很好。有什么想法吗?

//acquire the list template
$.get('tpl/listTpl.html', function(templates) {

//run underscore js on the list template and pass in the full collection of models
var template = _.template(templates, {list:app.collections.list.models});

//load the underscore template into the DOM
that.$el.html(template);

});

最佳答案

从 1.7.0 changelog :

Underscore templates no longer accept an initial data object. _.template always returns a function now.

您需要将代码更改为以下内容:

$.get('tpl/listTpl.html', function(templates) {
var template = _.template(templates);
var result = template({list:app.collections.list.models});
that.$el.html(result);
});

关于templates - 升级到 underscore 1.7 时出现模板错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25570559/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com