我正在从数组中删除一个元素:
this.my_events.splice(this.current_event);
this.current_event=null;
this.old_event=null;
jQuery('#eventModal').modal('hide');
当我在数组中添加三个或更多项目,然后删除其中任何一个时,它会删除所有项目并返回 null,而不刷新页面。我正在使用 Vue.js。
如果我刷新页面,则会显示这两个元素。这是什么问题?
最佳答案
您没有指定要删除的索引位置。
试试这个:
this.my_events.splice(index, 1); // the 1 represents how many items to delete
this.current_event=null;
this.old_event=null;
jQuery('#eventModal').modal('hide');
关于javascript - 拼接方法问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52430118/