data(){
oldpersonId:[],
personId:[]
}
methods:{
getData(){
this.oldpersonId=this.personId
//這會導致在其他方法里改變personId的數據的時候,這里的oldpersonId也會改變
}
}
解決辦法:
this.oldpersonId = [...this.personId]
this.oldpersonId = JSON.parse(JSON.stringify(this.personId))