Good morning, vue reported an error through the id jump details page.

the specific code is as follows
<template>
    <div class="detail">
        <dl v-for="(list,index) in detailData" :key="index">
            <dt>
                <img :src="list.avatar">
            </dt>
            <dd>
                <h2>{{list.title}}</h2>
            </dd>
        </dl>
    </div>
</template>

<script>
    import axios from "axios";
    export default {
        name: "detail",
        data() {
            return {
                id: 0,
                allData: [],
                detailData: []
            }
        },
        mounted() {

            this.id = this.$route.params.id;
            // console.log(this.id)
            axios.get("/api").then(res => {
                
                this.allData = this.allData.push(res.data);
                console.log(this.allData)
                this.detailData = this.allData.filter((v, i) => {
                    // console.log(this.detailData)
                    return v.id == this.id;
                });
            })
        },
    }
</script>
print console.log (this.allData) should be input received Json data, but print result is 1;

No error was reported in the service, and id also got

.
Dec.04,2021

this.allData = this.allData.push(res.data); //??????
The

push method returns the new length of the array after adding elements. How can you use the filter method

if the assignment becomes a Number type?
Menu