props父组件传值 子组件接收

props父组件传值 子组件接收

  • 小菜鸟

> 父组件传入值
> // 用 v-bond="post" 传入
 
retutn{
	 post: {
	            background:'#fff',
	            width:296,
	            height:231
      	  },
}
 
子组件接收  检测类型   type: Number,  传过来的值与接收的值类型不一样,会报错,
  props: {
     width:{
            type: Number,
             default:296,
      },
     height:{
          type:Number,
          default:231,
      },
     background:{
          type:String,
          default:'#fff'
      },

  },

> 在子组件里div里面使用传过来的值

  

你可能感兴趣的:(vue)