javascript .push() inserts the same object every time

前端 未结 2 911
故里飘歌
故里飘歌 2020-11-30 15:52

I dont know what I am doing wrong, but I cant push object to an existing object. I have boxes, and calculator, ... after click on box \".items\"

...
2条回答
  •  孤城傲影
    2020-11-30 16:21

    It's because there is only one object. You never update "activeItem" to reference a new object. Whenever you want to start on a new item, you need to start with a new object:

    activeItem = {};
    

提交回复
热议问题