easyui组件能new吗?

q631263135 2013-04-08 10:31:35
easyui帮助文档上实例化组件的方式有两种:
1.Creation from markup is even easier. Add 'easyui-panel' class to <div/> markup.

<div id="p" class="easyui-panel" title="My Panel"
style="width:500px;height:150px;padding:10px;background:#fafafa;"
data-options="iconCls:'icon-save',closable:true,
collapsible:true,minimizable:true,maximizable:true">

<p>panel content.</p>
<p>panel content.</p>
</div>

</div>
2.Create Panel programatically
<div id="p" style="padding:10px;">  
<p>panel content.</p>
<p>panel content.</p>
</div>

$('#p').panel({
width:500,
height:150,
title: 'My Panel',
tools: [{
iconCls:'icon-add',
handler:function(){alert('new')}
},{
iconCls:'icon-save',
handler:function(){alert('save')}
}]
});

我想知道除了这两种方式,能使用new吗?像这样:

var panel = new easyui.panel(
{
properties:...;
events:...;
}
);
...全文
112 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
UEAnswer 2013-04-08
  • 打赏
  • 举报
回复
在javascript基本很少用到new的方式产生对象,并且不推荐。new 基本是为了迎合其他面向对象的编程语言而设计的,对javascript没有太大意义,完全可以不适用new,各大js类库很少有使用new的方式。
「已注销」 2013-04-08
  • 打赏
  • 举报
回复
这样不是很好吗?为什么要用new吗,你试下

new jQuery.fn.init('#p').panel({  
  width:500,  
  height:150,  
  title: 'My Panel',  
  tools: [{  
    iconCls:'icon-add',  
    handler:function(){alert('new')}  
  },{  
    iconCls:'icon-save',  
    handler:function(){alert('save')}  
  }]  
}); 

87,992

社区成员

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

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