Last active
August 29, 2015 14:05
-
-
Save otakustay/6c5d25c1ef1083b26f33 to your computer and use it in GitHub Desktop.
private property solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(function (require) { | |
// 参考http://wiki.ecmascript.org/doku.php?id=harmony:private_name_objects | |
// 在不支持private names的现在,使用字符串来表示,日后能很方便地切换成private names | |
var names = { | |
handleSubmit: '_handleSubmit', | |
doValidate: '_doValidate' | |
}; | |
var exports = {}; | |
exports[names.handleSubmit] = function () { | |
// ... | |
this[names.doValidate](); | |
}; | |
// 公有和保护方法不变 | |
exports.validate = function () {}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
最后是要这样吧。感觉有点烦
exports[name.handleSubmit] = function () {
// ...
thisname.doValidate;
};