寒假前端学习Day4(Vue)
组件
组件的引入就是需要在<setup>
中引入子组件的模块,然后在模板中使用组件。
1 |
|
1 |
|
Props
这是用于父子组件之间通信,父组件将数据传输给子组件然后就可以。
在子组件中定义props
1 |
|
可以看到在子组件中定义了prop然后再子组件的模板中挂上msg
1 |
|
所以父组件可以通过greeting传输数据给子组件然后子组件改变msg。
寒假前端学习Day4(Vue)
https://ljw030710.github.io/2024/02/17/寒假前端学习Day4-Vue/