Uncaught Reference Error Waves未定义RequireJs

时间:2016-11-07 08:48:18

标签: javascript jquery requirejs

对requirejs来说是新手,我从这种加载依赖关系的方式开始

<script src="vendors/bower_components/jquery/dist/jquery.min.js"></script>
<script src="vendors/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>

<script src="vendors/bower_components/flot/jquery.flot.js"></script>
<script src="vendors/bower_components/flot/jquery.flot.resize.js"></script>
<script src="vendors/bower_components/flot.curvedlines/curvedLines.js"></script>
<script src="vendors/sparklines/jquery.sparkline.min.js"></script>
<script src="vendors/bower_components/jquery.easy-pie-chart/dist/jquery.easypiechart.min.js"></script>

<script src="vendors/bower_components/moment/min/moment.min.js"></script>
<script src="vendors/bower_components/fullcalendar/dist/fullcalendar.min.js"></script>
<script src="vendors/bower_components/simpleWeather/jquery.simpleWeather.min.js"></script>
<script src="vendors/bower_components/Waves/dist/waves.min.js"></script>
<script src="vendors/bootstrap-growl/bootstrap-growl.min.js"></script>
<script src="vendors/bower_components/sweetalert/dist/sweetalert.min.js"></script>
<script src="vendors/bower_components/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js"></script>

使用Requirejs

加载我的依赖项的方式
// Config File for Require js

requirejs.config({
shim: {
    bootstrap: { "deps": ['jquery'] },
    jqueryflot: { "deps": ['jquery'] },
    jqueryflotresize: { "deps": ['jquery'] },
    curvedline: { "deps": ['jquery'] },
    sparkedlines: { "deps": ['jquery'] },
    bootstrapgrowl: { "deps": ['jquery'] },
    sweetalert: { "deps": ['jquery'] },
    customscroll: { "deps": ['jquery'] },
    waves: { "deps": ['jquery'] },
    autosize: { "deps": ['jquery'] },
    timeago: { "deps": ['jquery'] },
    datetimepicker: { "deps": ['jquery'] },
    moment: { "deps": ['jquery'] },
    appmin: { "deps": ['jquery', 'customscroll', 'waves', 'datetimepicker'] }

},
baseUrl: 'lib',
paths: {
    jquery: 'vendors/bower_components/jquery/dist/jquery.min',
    bootstrap: 'vendors/bower_components/bootstrap/dist/js/bootstrap.min',
    jqueryflot: 'vendors/bower_components/flot/jquery.flot',
    jqueryflotresize: 'vendors/bower_components/flot/jquery.flot.resize',
    curvedline: 'vendors/bower_components/flot.curvedlines/curvedLines',
    sparkedlines: 'vendors/sparklines/jquery.sparkline.min',
    waves: 'vendors/bower_components/Waves/dist/waves.min',
    bootstrapgrowl: 'vendors/bootstrap-growl/bootstrap-growl.min',
    sweetalert: 'vendors/bower_components/sweetalert/dist/sweetalert.min',
    customscroll: 'vendors/bower_components/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min',
    autosize: 'vendors/bower_components/autosize/dist/autosize.min',
    moment: 'vendors/bower_components/moment/min/moment.min',
    datetimepicker: 'vendors/bower_components/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min',
    appmin: 'js/app.min',
    global: 'js/global',
    menu: 'js/menu',
    loan: 'js/loan',
    login: 'js/login',
    payment: 'js/payment',
    timeago: 'js/timeago',
    suggestion: 'js/suggestions',
    settings: 'js/settings',
    contributions: 'js/contributions',
    profile: 'js/profile',
    dashboard: 'js/dashboard'

}
});

然后在我的dashboard.html我加载文件

<script data-main="lib/js/config" src="lib/js/Requirejs.js"></script>

<script>
    require(['config'], function(){
        require(['js/libraryloaders/loadDashboardLibraries']);
        require(['js/dashboardjsloader']);
    });
</script>

但我得到的错误是在app.min.js中它说Waves未定义因此引用错误正在阻止我的dashboard.html正确加载。似乎第三方图书馆app.min.js正在利用波浪,甚至在使用shim之后我仍然得到参考错误

dashboardjsloader.js的代码如下

define(['jquery', 'bootstrap', 'sparkedlines', 'waves', 'bootstrapgrowl',
'sweetalert', 'customscroll', 'appmin'], function ($, plot) {



});

0 个答案:

没有答案