// 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>
では動作しません。
- .jsファイルのコードが正常に実行されます。 ✓
- ページの読み込み後にコンソールにペーストされます。 ✓
デバッガブレークポイント時に貼り付けられませんでした。 ✘
_.templateSettings = { interpolate: /\{\{(.+?)\}\}/g } var template = _.template("Hello {{ name }}!"); template({name: "Mustache"});
エラー:
underscore.js:1461 Uncaught TypeError: Cannot read property 'call' of undefined
編集:下線バージョン1.8.3のtemplate({name: "Mustache"});
エラー:
var template = function(data) {
return render.call(this, data, _);
};
アンダースコアのバージョンは?貼り付けられたコードのどの行がエラーをトリガーしますか?あなたが使用しているunderscore.jsのバージョン1461はどうなっていますか? –
回答(編集を参照) – Ashbury
ブレークポイントはどこですか?アンダースコアの中にありますか? –