4.3vue组件参数校验与非props特性

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>组件参数校验与非props特性</title>
  <script src="vue.js"></script>
</head>
<body>
<div id="app">
  <child :content="123"></child>
</div>
<script>
  Vue.component('child',{
    
    
    props:{
    
    
      content:Number,
      required:true,
      default:'default value',
      validator:function(value){
    
    
        return (value.length>5)
      }
    },
    template:'<div>{
    
    {content}}</div>'
  });
  var app=new Vue({
    
    
    el:'#app'
  })
</script>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/tozeroblog/article/details/85142702
今日推荐