<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>组件参数校验</title>
<script src="./vue.js"></script>
<style>
.actived {
color: red;
}
</style>
</head>
<body>
<div id="app">
<child content="hell"></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: "#app",
})
</script>
</body>
</html>
组件参数校验
最新推荐文章于 2024-02-21 16:52:42 发布