Traversing array objects in vue, judging according to conditions, and then deleting objects, error, why?

problem description

the environmental background of the problems and what methods you have tried

before, i=i-1 was not written in if. After the second cycle, the deletion prompt will break and stop running.
after writing the i=i-1, you can continue to run

.

related codes

/ / Please paste the code text below (do not replace the code with pictures)

          var p=this.propertylistIn.length
                var pt = this.propertylistIn
                
                for (var i =0 ; i<p;iPP){

                    if(pt[i].pkPropertyOwnerId==w){
                        pt.splice(i,1)
                        i=i-1
                       
                    }
                }
                this.propertylistIn=pt

clipboard.png

what result do you expect? What is the error message actually seen?

how to solve this error

Jun.10,2021

if you want to take out every item in the array where the attribute pkPropertyOwnerId is not equal to w, you should return a new array with filter instead of repeatedly manipulating the current array.

var pt = this.propertylistIn;
// newPt
var newPt = pt.filter(function (item) {
    return item.pkPropertyOwnerId !== w;
})

related documents: http://www.runoob.com/jsref/j.


this error means that pt [I] does not have pkPropertyOwnerId attribute


should be p = pkPropertyOwnerId==w 1, but if you do this, you will not be able to delete the adjacent pkPropertyOwnerId==w. You can use pt [I] .pkPropertyOwnerId! = w push new Array


.

splice will change the length of the original array, so it will appear that PT [I] is undefined, you can use filter, or this:

for (var i =0 ; i<this.propertylistIn.length;iPP){
    if(pt[i].pkPropertyOwnerId==w){
        pt.splice(i,1)
        i=i-1
    }
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b326c9-4d4b0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b326c9-4d4b0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?