关于require js加载的时候报错的问题

1.在项目中使用了requery.js  页面总是会出项一些奇怪的错误,如下

 

后来经过查找资料才发现,原来是因为依赖 的问题,因为require加载的时候是异步加载,而js之间是有相互依赖的,所以解决办法就是在加载之前添加依赖即可

require.config({
    baseUrl:path+'/ui/common/',
    paths:{
       'jquery':'js/libs/jquery-1.9.1',
       'domReady':'js/functionality/domReady',
       'jquery.jqGrid':'plugins/other/jqgird/jquery.jqGrid.min',
       'ztree.core':'plugins/other/ztree/jquery.ztree.core',
       'ztree.excheck':'plugins/other/ztree/jquery.ztree.excheck',
       'jquery.validator':'plugins/formElems/newValidator/js/jquery.validator',
       'zh-CN':'plugins/formElems/newValidator/js/zh-CN',
       'util':'js/functionality/Util',
       'DialogBySHF':'plugins/formElems/dialogbyshf/js/DialogBySHF',
       'alert':'plugins/modals/alertBox/AlertBox',
       'WdatePicker':'plugins/formElems/time/DatePicker97/WdatePicker',
        'bootstrap_datetimepicker':'plugins/formElems/time/bootstrap_datetimepicker/js/bootstrap-datetimepicker.min',
        'bootstrap_datetimepicker_zh_CN':'plugins/formElems/time/bootstrap_datetimepicker/js/bootstrap-datetimepicker.zh-CN',
        'echart':'plugins/chart/echarts.min',
       'nicescroll':'plugins/other/nicescroll/jquery.nicescroll.min',
       'bootstrap':'plugins/other/ipanel/bootstrap.min',
       'jquery-ui':'plugins/other/jquery-ui/jquery-ui.min',
       'content':'plugins/other/ipanel/content.min',
       'tree':'plugins/formElems/downTree/ztreeSelect',
    },
//关键部分
    shim:{
        'jquery-ui':{deps:['jquery']},
        'content':{deps:['jquery']},
                'bootstrap':{deps:['jquery']},
                'ztree.core':{deps:['jquery']},
                'ztree.exchedk':{deps:['ztree.core']}
    }
});                                    

 

转载于:https://www.cnblogs.com/pengfei25/p/7778388.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值