The length of the array printed by console is different

project.peopleList ({

)
            "projectId": that.id
        }, function(data) {
            console.log("data",data);
            // 
            that.peopleLists = [];//push
            for(var i = data.length - 1; i>=0; i--){
                if(data[i].peopleId == that.currentPeople){
                    data.splice(i,1)
                }else{
                    that.peopleLists.push(data[i]);
                    that.$emit("update:peopleLists",that.peopleLists)
                }
            }
        })
The

interface returns three pieces of data, but the printed result is as follows:
clipboard.png
removing the for loop shows normal. If you want to know what causes this phenomenon, thank you

.
May.10,2022

do a little experiment:

clipboard.png

console.log(arr) console.log(arr.toString())devtool (3) [1, 2, 3] console.dir(arr) Array(3)

(3) [1, 2, 3] console.log arr.toString() for splice;
Array(3) console.dir arr

console.xxx arr log dir splice

console.log(JSON.stringify(arr)) watch


chormeconsoleconsolelengthforconsoledata


console.log JSON.parse(JSON.stringify(...)) debugger


, 3, 3, for1, ,2, 2; console.log("data",data)for.


,

clipboard.png

just put the mouse up and you'll know

Menu