Mootools 1.4 官方网站的API使用说明存在错误
来源:互联网 发布:专业处理淘宝售假申诉 编辑:程序博客网 时间:2024/06/05 14:40
今天有人在群里问为何给Number用extend扩展的时候总是出错,我记得前几天阅读Moo的源代码时好像发现Number好像是只能用implement来进行扩展,而extend似乎是给Function扩展用的,于是乎查了一下官方文档
http://mootools.net/docs/core/Core/Core
Type method: extend
Adds one or more functions to the type. These are static functions that accept for example other types to parse them into the type, or other utility functions that belong to the certain type.
Syntax:
myType.extend(name, method);
or
myType.extend(methods);
Arguments:
name - (string) The method name.
method - (function) The method function.
or
methods - (object) An object with key-value pairs. The key is the method name, the value is the method function.
Returns:
(object) The type.
Examples:
RegExp.extend('from', function(regexp, flags){
return new RegExp(regexp, flags);
});
Number.extend('parseCurrency', function(currency){
// takes a string and transforms it into a number to
// do certain calculations
});
看到没,这是官方的原文,我测试了一下这段示例,运行结果是错误的,提示说:.parseCurrency is not a function
下边是我的测试代码:
Number.extend('parseCurrency', function(currency){
alert(currency);
});
(1).parseCurrency('ff');
出错提示是:
(1).parseCurrency is not a function
[在這個錯誤中斷] (1).parseCurrency('ff');
通过这个错误就可以知道了,parseCurrency 并非是一个function,于是不死心再次阅读Moo的源码,发现Number确实只能用implement扩展.
由此可见官方的文档是有错漏的.
尽信书不如无书,希望初学Moo的朋友注意一下,不要被其误导了!
0 0
- Mootools 1.4 官方网站的API使用说明存在错误
- 错误处理 (廖雪峰的官方网站)
- CullingGroup API的使用说明
- Struts 官方网站有没有打包下载api的地方呀?
- Delphi API HOOK完全说明(存在错误的原文,含修正)
- [zt]Delphi API HOOK完全说明(存在错误的原文,含修正)
- mootools的学习资源
- MooTools
- MooTools
- hibernate的官方网站
- Excel的官方网站
- JMeter的官方网站
- Sun的java官方网站
- JDBC的官方网站
- spring的官方网站
- 官方网站的例子
- uboot的官方网站
- 廖雪峰的官方网站
- Qt C++中的关键字explicit .
- 总结自己在台湾的工作经历推测未来中国内陆的互联网趋势
- 上周六出去烤肉随便拍了几张
- Console命令详解,让调试js代码变得更简单
- Mootools 1.4.1操作多个节点及其与jquery的差异
- Mootools 1.4 官方网站的API使用说明存在错误
- Mootools 1.4中取得索引值的方法,类似jquery的Element.index()
- Mootools1.41的API翻译工作已经启动了,SVN已经搭建ok,感兴趣的欢迎加入
- 使用Javascript接收get传递的值
- 使用Mootools动态添加Css样式表代码,兼容各浏览器
- 分享一下Blackhand
- New Laptop - "check media fail" and then "No bootable devices"
- 分享一個用Mootools剛寫的小玩意
- suddenly backBai Dao