AJAX Prototype.js 的问题。

yuanetking 2007-02-10 07:19:42
我想利用Prototype.js的面向对象API编写自己的面向对象代码如下:
但是报错。:请大师解答。
this.initialize has no properties
[Break on this error] this.initialize.apply(this, arguments);
代码如下:
var Widget = new Object();
Widget.CodeInput = Class.create(); //这步里出错的。
Widget.CodeInput.prototype = {
initialize: function(element) {
alert(element);
},
getHint: function() {
//var va = this.element.getElementByClassName('hint')[0].value;
//alert(va);
}
}
...全文
341 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
tantaiyizu 2007-02-12
  • 打赏
  • 举报
回复
ssdsdddsdsddf01. 发表帖子
yorkane 2007-02-10
  • 打赏
  • 举报
回复
你的代码貌似也没有错,至少我这里运行正常,你可以看看你的prototype 类库是否完整
yorkane 2007-02-10
  • 打赏
  • 举报
回复
var Widget = {};
Widget.CodeInput = Class.create(); //这步里出错的。
Widget.CodeInput.prototype=Object.extend(Widget.CodeInput,{
initialize:function(element){alert(element);
},
getHint: function(){
//var va = this.element.getElementByClassName('hint')[0].value;
//alert(va);
}})
var a=new Widget.CodeInput('hello');

这个算是 prototype 的标准写法
yuanetking 2007-02-10
  • 打赏
  • 举报
回复
晕阿。create是函数。Prototype.js中是这么定义的。
var Class = {
create: function() {
return function() {
this.initialize.apply(this, arguments);
}
}
}

但是就是报这样的错误:
this.initialize has no properties
[Break on this error] this.initialize.apply(this, arguments);
SAsura 2007-02-10
  • 打赏
  • 举报
回复
Widget.CodeInput = Class.create;

52,797

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧