How to use VUE to implement deletion and undelete functions?
<p id="one">
<p>
<span>1</span>
<span>这是一条信息</span>
<span style="color: red">删除</span>
</p>
<p>
<span>2</span>
<span>这是一条信息</span>
<span style="color: red">删除</span>
</p>
</p>
<p id="two">
<p>
<span>2</span>
<span>这是一条信息</span>
<span style="color: green">撤销删除</span>
</p>
</p>
Finally, by clicking the button, you can get the deleted information and the information that has not been deleted.
仅有的幸福2017-05-19 10:14:38
When generating information, add the ID and use the ID to obtain the corresponding information
我想大声告诉你2017-05-19 10:14:38
When deleting, push the value to be deleted to an array delList
When undoing, pop out the last deleted value
function TM(arr){
this.arr = arr;
this.delArr = [];
this.remove = (val) => {
this.arr = this.arr.filter(e => e !== val);
this.delArr.push(val);
}
this.back = () => {
var val = this.delArr.pop();
this.arr.push(val);
return val;
}
}