农燊高科官方网站
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

main.js 2.3 KiB

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