Can't access object property, even though it shows up in a console log

后端 未结 30 1802
日久生厌
日久生厌 2020-11-22 06:26

Below, you can see the output from these two logs. The first clearly shows the full object with the property I\'m trying to access, but on the very next line of code, I can\

30条回答
  •  再見小時候
    2020-11-22 06:52

    I had the same issue today. Problem was caused by uglify-js. After I executed same non-uglified code problem was solved. Removing of

    --mangle-props
    

    from uglify-js was enough to have working uglified code.

    Perhaps, the best practice is to use some prefix for properties that has to be mangled with regex rule for uglify-js.

    Here is the source:

    var data = JSON.parse( content);
    ...
    this.pageIndex = parseInt(data.index);
    this.pageTotal = parseInt(data.total);
    this.pageLimit = parseInt(data.limit); 
    

    and here is how it was uglified:

    var n = JSON.parse( t);
    ...
    this._ = parseInt(n.index), this.g = parseInt(n.total), this.D = parseInt(n.C)
    

提交回复
热议问题