调试了半天,全都是复制代码惹得祸!

    上次由于一个'\t'让我郁闷了半天,本以为自己已经在debug的时候很小心了,没有想到今天又载了一会hitwall.gif。错误非常之低级,而debug费力又还非常之大,真是让人哭笑不得。所以干脆在blog的随笔里专门开辟一个叫"Debug中的滑铁卢"的分类,专门记录Debug时一些stupid的小事。

    其实Coding是挺枯燥的,这个我在说Whidbey的Snippets功能时就说过,而且特别是重复的Coding,更是让人烦躁angry_smile.gif。但是不管枯燥也好烦躁也罢,还是要写不。这时我们常常也会学学网站编辑,动用动用Ctrl+C & Ctrl+V大法。这不手艺欠佳,今天我就载在这个Ctrl+C、V上了,看来注定当不成网站编辑了(就这追求啊,浪费了我这么多时间看你这么些天瞎摆活了cry_smile.gif!)。

    今天这个问题其实超级的简单,真是too simple, too young ...,我在GetShowTab()方法前定义了两个方法,我写成这样的:

None.gif  DimTreeTab.prototype.ShowMemberTree  =   function ()
None.gif {
None.gif };
None.gif
None.gif DimTreeTab.prototype.ShowSearchMember 
=   function ()
None.gif {
None.gif };
None.gif
None.gif DimTreeTab.prototype.GetShownTab 
=   function ()
None.gif {
None.gif     
if  (  this .m_Panels[ 0 ].m_Element.style.display  ==  'inline' )
None.gif     {
None.gif         
//  . . .
None.gif
     }
None.gif };

    这时发现这两个函数里面需要用 this.m_Panels[0].m_Element.style.display。好啊,Ctrl+C & Ctrl+V,搞定!

None.gif  DimTreeTab.prototype.ShowMemberTree  =   function ()
None.gif {
None.gif     this.m_Panels[0].m_Element.style.display == 'inline' 
None.gif     this.m_Panels[0].m_Element.style.display == 'inline' 
None.gif };
None.gif
None.gif DimTreeTab.prototype.ShowSearchMember 
=   function ()
None.gif {
None.gif     this.m_Panels[0].m_Element.style.display == 'inline' 
None.gif     this.m_Panels[0].m_Element.style.display == 'inline' 
None.gif };

    改拨改拨,ok了~~

None.gif  DimTreeTab.prototype.ShowMemberTree  =   function ()
None.gif {
None.gif     this.m_Panels[0].m_Element.style.display == 'inline' 
None.gif     this.m_Panels[1].m_Element.style.display == 'none
None.gif };
None.gif
None.gif DimTreeTab.prototype.ShowSearchMember 
=   function ()
None.gif {
None.gif     this.m_Panels[0].m_Element.style.display == 'none
None.gif     this.m_Panels[1].m_Element.style.display == 'inline' 
None.gif };

    运行起来完全没有效果,由于对DHTML中的element引用关系比较复杂,老是觉得可能是没有引用到正确的element,就在this.m_Panels[n].m_Element里查啊查啊,查到花儿都谢了,还是没有查到问题emdgust.gif。最后都调试成这样了:

None.gif DimTreeTab.prototype.ShowMemberTree  =   function ()
None.gif{
None.gif    alert(
this .m_Panels[ 0 ].m_Element.outerHTML);
None.gif    
this .m_Panels[ 0 ].m_Element.style.display  ==  'inline';
None.gif    alert(
this .m_Panels[ 0 ].m_Element.outerHTML);
None.gif    alert(
this .m_Panels[ 1 ].m_Element.outerHTML);    
None.gif    
this .m_Panels[ 1 ].m_Element.style.display  ==  'none';
None.gif    alert(
this .m_Panels[ 1 ].m_Element.outerHTML);    
None.gif};
None.gif
None.gifDimTreeTab.prototype.ShowSearchMember 
=   function ()
None.gif{
None.gif    alert(
this .m_Panels[ 0 ].m_Element.outerHTML);
None.gif    
this .m_Panels[ 0 ].m_Element.style.display  ==  'none';
None.gif    alert(
this .m_Panels[ 0 ].m_Element.outerHTML);
None.gif    alert(
this .m_Panels[ 1 ].m_Element.outerHTML);    
None.gif    
this .m_Panels[ 1 ].m_Element.style.display  ==  'inline';
None.gif    alert(
this .m_Panels[ 1 ].m_Element.outerHTML);    
None.gif};

    才猛然发现,怎么赋值是"=="啊!!!hitwall.gifhitwall.gifhitwall.gif。正确的应该是:

None.gif DimTreeTab.prototype.ShowMemberTree  =   function ()
None.gif{
None.gif    
this .m_Panels[ 0 ].m_Element.style.display  =  'inline';
None.gif    
this .m_Panels[ 1 ].m_Element.style.display  =  'none';
None.gif};
None.gif
None.gifDimTreeTab.prototype.ShowSearchMember 
=   function ()
None.gif{
None.gif    
this .m_Panels[ 0 ].m_Element.style.display  =  'none';
None.gif    
this .m_Panels[ 1 ].m_Element.style.display  =  'inline';
None.gif};

    可能算不上什么教训,但是还是可以注意几点。Coding的时候,因该:

    打些字;
    查问题先查简单的;
    实在不行了,散散步回来做;
    让team里的哥们给看一下...

转载于:https://www.cnblogs.com/birdshome/archive/2005/03/02/110904.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值