< div id= "app" >
<child :content="12"></child>
<child :text="424241"></child>
</div>
<script>
Vue.component("child",{
template:`<div>{{content}}{{text}}</div>`,
props:{
content:[Number,String],
text:{
type:Number,
required:false,
default:"helloworld",
validator(value){
return value.length > 5
}
}
}
})
var vm=new Vue({
el:"-sharpapp",
})
</script>
Screenshot of error report:
my personal understanding: text="424241", isn"t the way passed in here like a static number?
official API: ide/components-props.html-sharp%E4%BC%A0%E5%85%A5%E4%B8%80%E4%B8%AA%E6%95%B0%E5%AD%97" rel=" nofollow noreferrer "> https://cn.vuejs.org/v2/guide.
, however, the first reason for reporting an error is that this is a string
. The second reason for reporting an error is also rather confusing. Doesn"t the "424241" length meet the requirements of the validator validator? Why did you report it wrong?
I hope the boss can help me with the answer. Thank you