Component parameter verification and props characteristics
default——default value;
required ture——must pass false or not pass;
validator——set the incoming value or report an error;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src='./vue.js'></script>
</head>
<body>
<div id="root">
<child content="a"></child>
</div>
<script>
Vue.component('child', {
props: {
content: {
type: String,
// required: false
// default: 'default value'
validator: function(value) {
return (value.length > 5)
}
}
},
template: '<div>{
{content}}</div>'
})
var vm = new Vue({
el: '#root'
})
</script>
</body>
</html>