Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
W
wiki-java
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Operations
    • Operations
    • Incidents
  • Analytics
    • Analytics
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • 老徐
  • wiki-java
  • Wiki
  • shuidi js develope

Last edited by 梅俊辉 Jul 08, 2016
Page history
This is an old version of this page. You can view the most recent version or browse the history.

shuidi js develope

水滴项目js开发规范
介绍: js/common/ 目录下, common.js封装了js常用的方法,common.string.js扩展了string对象,提供了如去空格,格式化等方法,还有时间的格式化函数
common文件夹下的其他js文件均不可再用

通常一个页面对应一个js文件,js文件中包含了关于此页面的所有js代码,js代码需要按照模板规定来开发,模板如下:

temp.js文件

/**

  • 创建了一个Temp对象, */ var Temp = Temp || {}; (function($){

/**

  • 所有的ajax方法都定义在这里 */ Temp.Ajax=(function(){

    /** 加载div内容的 ajax 回调函数方法 */ var loadDivContentCallback=function(data){ $("#all").text(data); };

    /** 加载div内容的的 ajax方法 */ var loadDivContentAjax=function(jsondata){ //创建ajax参数对象 var params=new AjaxObj(jsondata,"test/ajax",loadDivContentCallback); //调用common.js中的通用ajax方法 Pingan.ajax(params); };

    /**

    • 所有的ajax要执行的初始化事件定义在这里面 */ var ajaxInitExecute=function(){ loadDivContentAjax(); }

    return{ ajaxInit:ajaxInitExecute };

})();

//定义事件绑定 Temp.Event=(function(){

function show(){
	alert('test');
}

/**
 * 所有的js元素绑定事件写在这里
 */
var eventBind=function(){
	$("#clickMe").click(show);
};

//返回对象
return{
	eventInit:eventBind
};

})();

/**

  • 初始化方法
  • 所有要在页面加载后执行的代码都放在这里 */ $(function(){ Temp.Ajax.ajaxInit(); Temp.Event.eventInit();

});

})(jQuery);

Clone repository
  • git configuration and simple use
  • Home
  • java code specification
  • maven environment configuration
  • shuidi js develope
  • ucs_project environment configuration