0
我試圖讓幫助者用逗號返回一個號碼(例如100000 = 100,000)。它正確返回,但我得到一個錯誤出現在我的控制檯。將逗號加上號碼時出錯
Exception in template helper: TypeError: Cannot read property 'toString' of undefined
如果我console.log(value);
返回undefined
。
路徑:test.js
Template.registerHelper(
'formatCurrency', function(value) {
return value.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
},
);
路徑:test.html
{{formatCurrency compareSalary.userSalary}}
{{formatCurrency compareSalary.min}}