网站
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

75 行
2.6 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. echarts: 'lib/echarts/echarts.min', //echarts组件
  19. laydata:'lib/laydata/laydata',
  20. //自己写的路径配置
  21. Tools: 'common/tools',
  22. addressApi: 'api/index' //所有Ajax接口存放地
  23. },
  24. shim: {
  25. bootstrap: {
  26. deps: ['jquery']
  27. },
  28. jqueryLazyload: {
  29. deps: ['jquery']
  30. },
  31. dialog: {
  32. deps: ['jquery', 'dialogConf', 'drag', 'popup'],
  33. exports: 'dialog'
  34. },
  35. swiper: {
  36. deps: ['jquery'],
  37. exports: 'swiper'
  38. },
  39. nprogress: {
  40. deps: ['jquery'],
  41. exports: 'nprogress'
  42. }
  43. }
  44. });
  45. //所有页面都需要的js,先行加载
  46. require(['jquery', 'addressApi']);
  47. require(["jquery", "nprogress"], function ($, nprogress) {
  48. //ajax加载页面跳转
  49. $(document).ajaxStart(function () {
  50. // $('.loading').show();
  51. nprogress.start();
  52. }).ajaxStop(function () {
  53. // $('.loading').hide();
  54. nprogress.done();
  55. });
  56. //根据条件加载不同js文件
  57. var currentPage = $("#require-page").attr("current-page");
  58. var targetModule = $("#require-page").attr("target-module");
  59. if (targetModule) {
  60. // 页面加载完毕后再执行相关业务代码比较稳妥
  61. $(function () {
  62. require([targetModule], function (targetModule) {
  63. // 不要在这里写业务代码
  64. //全部统一调用init方法
  65. //也就是每个模块都暴露一个init方法用于事件监听,页面内容加载等
  66. targetModule.init(currentPage);
  67. });
  68. });
  69. return;
  70. }
  71. })