2
require.config({
paths: {
jquery: 'libs/jquery',
underscore: 'libs/underscore',
}
});
define([
'jquery',
'underscore',
], function($,_){
var test = _.template("hello: <%= name %>",{name:"warren"});
});
考慮使用requirejs加載jQuery和強調,爲什麼我收到此錯誤上面的代碼...Underscore.js遺漏的類型錯誤:無法調用空的方法「模板」
Uncaught TypeError: Cannot call method 'template' of null
所有JS似乎正在加載...錯誤指向_.template行。這讓我瘋狂......
這將表明你是正確的:http://stackoverflow.com/a/8156341/479863 –
也分叉版本,是AMD compat - https://github.com/amdjs/underscore –
謝謝,這成功了!正如你所提到的,我最終只是添加了下劃線文件。 – wcolbert