Invalid prop: type check failed for prop "modelValue". Expected Number with value 0, got String with value "0".
When checking the project, the console reported this warning
Translated by Youdao is: Invalid prop: The type check of the prop "modelValue" failed. Expected a number with value 0, got string with value "0".
At the beginning, I didn’t understand the meaning of it. Developers who have met or worked for a while may know what it means, but as a rookie who is new to the industry, I can’t understand this warning at all, so I still ask It’s only after the boss knows what this means. In simple terms, it is: what you want to get is a number, but what you pass is a string.
My first thought was: Shouldn't I define an array outside when I add data to it? As a result, I found out after a long time that it was not a problem with the array at all, but a problem with the data structure in the array!
The data structure given to me by the backend is: [
{ "questionTitle": "Single Choice Question", "examSubjectCode": "5e6234a8-6bf0-43cd-8256-b81ce18d06fc", "questionCount": 20, "score": 3 }, { "questionTitle": "True or False", "examSubjectCode": "5e6234a8-6bf0-43cd-8256-b81ce18d06fc", "questionCount": 30, "score": 2 }, { "questionTitle": "Multiple choice", "examSubjectCode": "5e6234a8-6bf0-43cd-8256-b81ce18d06fc", "questionCount": 20, "score": 4 } ]
And the data structure I defined myself is like this:
Just change the circled ones to numbers.
Ok, successfully resolved the string of yellow warnings