// 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
斷點在哪裏?它是否在下劃線? –