1.props验证总是报错
2.相关代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="../lib/vue.js"></script>
</head>
<body>
<div id="app">
<example :propC="100"></example>
</div>
</body>
<script type="text/javascript">
Vue.component('example', {
props: {
propC: {
type: String,
required: true
},
propD: {
type: Number,
default: 100
}
},
template: '<h1>{{propC}}-{{propD}}</h1>'
})
var vm = new Vue({
el: '#app',
data: {
msg: 'hello world',
num: 100
}
})
</script>
</html>
运行结果:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…