我试着在通过RequireJS加载Bootstrap之后使用它。尝试了几乎所有的方法,但仍然得到了:Uncaught TypeError: $(...).modal is not a function
配置:
require.config({
paths: {
jquery: 'vendor/jquery-1.10.2.min',
underscore: 'vendor/lodash',
backbone: 'vendor/backbone.min',
text: 'vendor/plugins/text',
bootstrap: 'vendor/bootstrap.min'
},
shim: {
bootstrap: {deps : ['jquery'], exports: '$'}
}
});
require([
'app',
'bootstrap'
], function(App){
App.initialize();
});应该使用modal()的文件
define([
'jquery',
'underscore',
'backbone',
//...
'bootstrap'
], function($, _, //...
){
//.......
renderPlaceForm: function(e) {
e.preventDefault();
$('#place-modal').modal('show');
}
//.....我也试着省略了"exports",在App中加载bootstrap也是我的尝试之一。怎么啦?
发布于 2016-06-17 17:30:10
检查它是否可以与jQuery(...).modal一起使用。您的jQuery可能处于兼容模式,同时检查jQuery和bootstrap是否未包含两次。
https://stackoverflow.com/questions/37876752
复制相似问题