1.可以声明一个变量,在变量里面写对应的方法。如:
$(function () { var salaryPoll_detail={ init:function(){ that = this; that.start(); that.list(); }, start:function(){
.../ }, list:function(){ .../ }, } salaryPoll_detail.init();})
2.多个js文件存在时,公共方法js 可以用window声明,调用widow变量里面的方法,如
a.js
$(function () {
window..salaryPoll_detail={ init:function(){ that = this; that.start(); that.list(); }, start:function(){
.../ }, list:function(){ .../ }, } salaryPoll_detail.init();})
b.js
$(function () {
window.detail={ init:function(){ that = this; that.start(); }, start:function(){
salaryPoll_detail.list(); //调用a.js里面的list方法 }, } detail.init();})
新闻热点
疑难解答