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
        }
}
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-1b3e0f2-2bc37.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-1b3e0f2-2bc37.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?