Tôi đang sử dụng jquery, backbonejs, underscorejs và bootstrap cho dự án của công ty tôi. Đôi khi tôi gặp lỗi này trong chrome.Bootstrap - Uncaught TypeError: Không thể đọc thuộc tính 'fn' của undefined
Uncaught TypeError: Cannot read property 'fn' of undefined
shim của tôi là như thế này trong main.js tôi
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();
});
Tôi đã chèn .noConflict() cho jquery, underscorejs và backbonejs.
app.js My
// 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
};
});
Đây là ảnh chụp màn hình từ chrome của tôi
nó loại như liên quan đến bootstrap.
Cảm ơn rất nhiều trước.
Cách sử dụng 'noConflict'? –
[answer] (http://stackoverflow.com/a/11184070/122005) này có thể hữu ích – chridam