The calculated property returns the props parameter. The Times does not define an exception.

props: ["item"],
computed: {
        coinPrice () {
            return this.item.currentPrice.toFixed(2)
        }
}

is it strange that the undefined exception of the report is loaded for the first time? I checked that Baidu said that the result of the data request was executed asynchronously, so the first load report did not define an exception, so how to solve it?

Nov.29,2021

give the default value

props: {
    item:{
        type: Object,
        default: () => ({currentPrice:0})
    }
}

does your sub-component pass the wrong value

clipboard.png


solve the problem, define an attribute in data to receive the value in props, and then calculate it with the attribute in data. Perfect
props: ['item'],
computed: {

    coinPrice () {
        return this.i.currentPrice.toFixed(2)
    }

}
data () {
return {

i:item

}
}


computed: {
        coinPrice () {
            return typeof this.item.currentPrice === 'number' ? this.item.currentPrice.toFixed(2) :         
             this.item.currentPrice
        }
}
Menu