vue 中的父子组件传值

1. 父组件给子组件传值:

vue中父组件给子组件传值使用的是props;

1.首先在我的父组件中引入我的子组件:


9898993-79816b01ded1a212.png

然后将组件挂载注册,在template中引用:

9898993-5570659fce35f204.png

在我的子组件中使用props:


9898993-b6de9303a348a9c8.png

2. 子组件给父组件传值:子组件传值给父组件利用事件绑定:在我的父组件中:


9898993-0fe08d17c6d1cb97.png


9898993-7f132ab19228cafa.png

猜你喜欢

转载自blog.csdn.net/weixin_34279061/article/details/87235831