以下是我测试页面的代码,正常没什么问题,但是偶尔刷新后会出现bootstrap先于jquery加载,从而报错。
还有的时候所有js都加载且正常执行完后,浏览器还在不停的loading,也没有任何网络请求。
哪位帮忙看看为什么,谢谢
requirejs.config({
baseUrl: 'lib',
paths: {
jquery: 'jquery/jquery.min',
bootstrap: 'bootstrap/js/bootstrap.min',
datatables: 'datatables/js/jquery.dataTables.min',
common: '../js/common'
},
shim: {
bootstrap: {
deps: ['jquery']
},
datatables: {
deps: ['bootstrap']
}
}
});
define(['jquery', 'bootstrap', 'datatables'], function($) {
return {
data: '123',
$: $
};
});
define(['common'], function(main) {
main.$('#test1').html('1111111111');
main.$('.table').dataTable({
"bPaginate": false,
"bFilter": false,
"bInfo": false,
"bAutoWidth": true,
"aaSorting": [],
"oLanguage": {"sZeroRecords": "无更多记录", "sEmptyTable": "无更多记录"}
});
});
页面上
<script data-main="require.config.js" src="lib/requirejs/require.js?1446736246"></script>
<script>
require(['js/analytic/index'], function(){
});
</script>