父子组件传参:
第一种方式:
1,子组件需要用到父组件传过来的属性:
父组件使用子组件时增加属性:tem-id="id"
子组件用props: {temId: {type: Number,default: null}}接收;
子组件使用temId时直接用this.temId。
第二种方式:
2,父组件使用子组件时增加ref属性,父组件想要使用子组件里的方法时,
直接用this.$refs.ref名.子组件里定义的方法;
vue父子组件传参
最新推荐文章于 2024-03-26 14:57:51 发布