[英]How i can mark function as “private” to renaming it by Google Closure Compiler?
我有私有函数createSomething():
function Player(id) {
/**
* Creates stuff
* @private
*/
this.createSomething = function() {
// do something good
};
}
并且我想在使用Google Closure Compiler编译源代码后看到重命名的函数“ createSomething()”。 是的,我知道ADVANCED_OPTIMIZATIONS,但它与jQuery和其他库不兼容。
解决方案是使用字符串文字来引用属性。
function Player(id) {
/**
* @private
*/
this['createSomething'] = function() {
// do something good
};
}
之所以可行,是因为编译器从不重命名字符串文字。 不过要小心。
您可以使用ADVANCED_OPTIMIZATIONS编译代码,但仍与其他库兼容。 你需要了解的库文件中实习医生和出口 :
不用这个就可以使用
function Player(id) {
/**
* Creates stuff
* @private
*/
createSomething = function() {
// do something good
};
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.