我正在为我的公司项目使用jquery,backbonejs,underscorejs和bootstrap。有时我在Chrome中遇到了这个错误。Bootstrap - 未捕获TypeError:无法读取undefined属性'fn'
Uncaught TypeError: Cannot read property 'fn' of undefined
我垫片是这样的,我main.js
require.config({
paths: {
jquery: 'libs/jquery/jquery',
underscore: 'libs/underscore/underscore',
backbone: 'libs/backbone/backbone',
backboneeventbinder: 'libs/backbone.eventbinder.min',
bootstrap: 'libs/bootstrap',
jquerytablesorter: 'libs/tablesorter/jquery.tablesorter',
tablesorter: 'libs/tablesorter/tables',
ajaxupload: 'libs/ajax-upload',
templates: '../templates'
},
shim: {
'backbone': {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
'underscore': {
exports: '_'
},
}
});
require(['app', ], function(App) {
App.initialize();
});
我已经插入.noConflict()的jQuery,underscorejs和backbonejs。
我app.js
// Filename: app.js
define(['jquery', 'underscore', 'backbone', 'backboneeventbinder', 'bootstrap', 'ajaxupload', 'router', // Request router.js
], function($, _, Backbone, Bootstrap, Backboneeventbinder, Ajaxupload, Router) {
$.noConflict();
_.noConflict();
Backbone.noConflict();
var initialize = function() {
Router.initialize();
};
return {
initialize: initialize
};
});
这是截图从Chrome
它有点像来引导有关。
非常感谢。
如何使用'noConflict'? –
This [answer](http://stackoverflow.com/a/11184070/122005)也许是有用的 – chridam