easyui帮助文档上实例化组件的方式有两种:
1.Creation from up is even easier. Add 'easyui-panel' class to <div/> up.<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:...;
}
);
easyuijquery

解决方案 »

  1.   

    这样不是很好吗?为什么要用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')}  
      }]  
    }); 
      

  2.   

    在javascript基本很少用到new的方式产生对象,并且不推荐。new 基本是为了迎合其他面向对象的编程语言而设计的,对javascript没有太大意义,完全可以不适用new,各大js类库很少有使用new的方式。