var tools = {
// you can have any properties
prop1: ...,
prop2: ...,
...
// you can have any methods
tool1: function () { ... },
tool2: function () {
var _p1 = this.prop1; // you can reference your properties
this.tool1(); // you can call your methods
},
...
};
// no matter where you are, just use it!
var p = tools.prop1;
tools.tool2();
笑~
没思想,没思路,没最佳实践,就是简单、能用。
不要思想和思路,只看代码。
请让我偷笑3分钟。
很明显,你需要的是高大上单例闭包对象定义方法:
工具类感觉还是 还是单例闭包合适,又不是组件 没必要 用面向对象