网站
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

70 lines
2.4 KiB

  1. requirejs.config({
  2. urlArgs: "ver=1.0_" + (new Date).getTime(),
  3. baseUrl: '/static/js/',
  4. paths: {
  5. //第三方库的路径配置
  6. jquery: 'lib/jquery/jquery-1.9.1.min', //jquery
  7. bootstrap: 'lib/bootstrap/js/bootstrap.min', //bootstrap
  8. jqueryCookie: 'lib/jquery-cookie/jquery.cookie', //cookie插件
  9. template: 'lib/template/template', //模板引擎
  10. templaten: 'lib/template/template-native', //模板引擎-后端写法
  11. jqueryLazyload: 'lib/jQuery-plugins/jquery.lazyload.min', //图片延迟加载
  12. dialog: 'lib/dialog/dialog', //artDialog弹窗插件
  13. dialogConf: 'lib/dialog/dialog-config',
  14. drag: 'lib/dialog/drag',
  15. popup: 'lib/dialog/popup',
  16. swiper: 'lib/swiper/swiper.min', //焦点图插件
  17. nprogress: 'lib/nprogress/nprogress', //页面加载loading组件
  18. //自己写的路径配置
  19. Tools: 'common/tools',
  20. addressApi: 'api/index' //所有Ajax存放地
  21. },
  22. shim: {
  23. bootstrap: {
  24. deps: ['jquery']
  25. },
  26. jqueryLazyload: {
  27. deps: ['jquery']
  28. },
  29. dialog: {
  30. deps: ['jquery', 'dialogConf', 'drag', 'popup'],
  31. exports: 'dialog'
  32. },
  33. swiper: {
  34. deps: ['jquery'],
  35. exports: 'swiper'
  36. },
  37. nprogress: {
  38. deps: ['jquery'],
  39. exports: 'nprogress'
  40. }
  41. }
  42. });
  43. //所有页面都需要的js,先行加载
  44. require(['jquery', 'nprogress', 'addressApi']);
  45. require(["jquery"], function ($) {
  46. //ajax加载页面跳转
  47. $(document).ajaxStart(function () {
  48. $('.loading').show();
  49. }).ajaxStop(function () {
  50. $('.loading').hide();
  51. });
  52. //根据条件加载不同js文件
  53. var currentPage = $("#require-page").attr("current-page");
  54. var targetModule = $("#require-page").attr("target-module");
  55. if (targetModule) {
  56. // 页面加载完毕后再执行相关业务代码比较稳妥
  57. $(function () {
  58. require([targetModule], function (targetModule) {
  59. // 不要在这里写业务代码
  60. //全部统一调用init方法
  61. //也就是每个模块都暴露一个init方法用于事件监听,页面内容加载等
  62. targetModule.init(currentPage);
  63. });
  64. });
  65. return;
  66. }
  67. })