1. 父组件给子组件传值:
vue中父组件给子组件传值使用的是props;
1.首先在我的父组件中引入我的子组件:
![](https://img.haomeiwen.com/i9898993/79816b01ded1a212.png)
然后将组件挂载注册,在template中引用:
![](https://img.haomeiwen.com/i9898993/5570659fce35f204.png)
在我的子组件中使用props:
![](https://img.haomeiwen.com/i9898993/b6de9303a348a9c8.png)
2. 子组件给父组件传值:子组件传值给父组件利用事件绑定:在我的父组件中:
![](https://img.haomeiwen.com/i9898993/0fe08d17c6d1cb97.png)
![](https://img.haomeiwen.com/i9898993/7f132ab19228cafa.png)
1. 父组件给子组件传值:
vue中父组件给子组件传值使用的是props;
1.首先在我的父组件中引入我的子组件:
然后将组件挂载注册,在template中引用:
在我的子组件中使用props:
2. 子组件给父组件传值:子组件传值给父组件利用事件绑定:在我的父组件中:
本文标题:vue 中的父子组件传值
本文链接:https://www.haomeiwen.com/subject/nvwcvftx.html
网友评论