javascript - How to use vue.js to implement deletion and undelete functions?
phpcn_u1582
phpcn_u1582 2017-05-19 10:12:38
0
2
776

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.

phpcn_u1582
phpcn_u1582

reply all(2)
仅有的幸福

When generating information, add the ID and use the ID to obtain the corresponding information

我想大声告诉你

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; 
    }
}

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template