簡體   English   中英

調試以對象文字模式編寫的javascript嗎?

[英]debug javascript written in object literal pattern?

我有一些像

var innerPage = {

/* declare vars, cache selectors */
leftWidth           : $("#episodes-nav").width(),
right               : $("#episodes-right"),
theWindow           : $(window),
heroImageHolder     : $("#hero-image-holder"),
heroImage           : $("#hero-image"),

whiteOverlay        : $("#white-overlay"),
tilesContainer      : $("#tiles-container"),


heroPercentToShow   : 0.6,
// heroHolderWidth      : this.heroImageHolder.width(),
// heroHolderHeight : this.heroImageHolder.height(),

heroImgRealW        : null,
heroImgRealH        : null,

/* init */
init                : function(){
    var that = this;
    this.heroImage.on('load', function(){
        // image loaded .. do something
        that.heroImgRealW = this.naturalWidth;
        that.heroImgRealH = this.naturalHeight;
        that.fitHeroImage();

        that.buildInnerBlocks();  
    });

},


fitHeroImage        : function(){

    var desiredWidthToFit = this.heroPercentToShow * this.heroNaturalW;
    var scaleRatio = this.heroViewportWidth / desiredWidthToFit;
    //trace(scaleRatio);

    this.heroImage.width( this.heroImage.width() * scaleRatio );
    var offsetSides = (600 -this.heroImage.width() ) / 2;
    var offsetTop = (containerHeight -this.heroImage.height() ) / 2;
    //trace("top"+offsetTop);
    this.heroImage.css("left", offsetSides);
    this.heroImage.css("top", offsetTop);

    this.heroImage.height( this.heroImage.height() * scaleRatio );
},

/* destroy */
destroy             : function(){

},

/* sizeChildren */
sizeChildren        : function(){

    this.right.width( this.theWindow.width() -  this.leftWidth );
    this.whiteOverlay.width( this.right.width() - this.heroImageHolder.width() +2000 );
    this.tilesContainer.width( this.whiteOverlay.width() );

    this.fitHeroImage();

    //$("#tiles-container").empty();
}


}

當我在函數上或函數內部設置斷點時,它們不會被觸發(在chrome中測試)。 我該如何解決?

調用這些函數時,函數中的斷點將觸發,但在創建innerPage進行檢查后,應該可以設置斷點。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM