Uncaught TypeError: Cannot assign to read only property

后端 未结 3 2144
执念已碎
执念已碎 2020-12-15 14:42

I was trying out this really simple example from the awesome \"Professional JavaScript for Web Developers\" book by Nicholas Zakas but I can\'t figure what I am doing wrong

3条回答
  •  执念已碎
    2020-12-15 15:32

    I tried changing year to a different term, and it worked.

    public_methods : {
        get: function() {
            return this._year;
        },
    
        set: function(newValue) {
            if(newValue > this.originYear) {
                this._year = newValue;
                this.edition += newValue - this.originYear;
            }
        }
    }
    

提交回复
热议问题