// run with console open
//and paste following when you hit the debugger:
/*
_.templateSettings = {
interpolate: /\{\{(.+?)\}\}/g
};
var template = _.template("Hello {{ name }}!");
console.log(template({name: "Mustache"}))
*/
debugger
//should return:
//underscore-min.js:5Uncaught TypeError: Cannot read property 'call' of undefined
//out of debugger though, it works:
_.templateSettings = {
interpolate: /\{\{(.+?)\}\}/g
};
var template = _.template("Hello {{ name }}!");
console.log(template({name: "Mustache"}))
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
工作,我不能运行underscore's sample template代码,同时在调试器(我想在控制台实际数据播放)。在.js文件
- 代码运行正常。 ✓在页面加载运行正常后,将
- 粘贴到控制台中。 ✓
在调试器断点时粘贴 - 不工作。 ✘
_.templateSettings = { interpolate: /\{\{(.+?)\}\}/g } var template = _.template("Hello {{ name }}!"); template({name: "Mustache"});
错误:
underscore.js:1461 Uncaught TypeError: Cannot read property 'call' of undefined
编辑:于template({name: "Mustache"});
的下划线版本1.8.3 Line 1461
错误:
var template = function(data) {
return render.call(this, data, _);
};
下划线的哪个版本?粘贴代码中的哪一行触发错误?您正在使用的underscore.js版本的第1461行是什么? –
已回答(请参阅编辑) – Ashbury
断点在哪里?它是否在下划线? –