网站
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

main.js 2.6 KiB

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