-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[vue] vue组件之间的通信都有哪些? #228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
|
|
1.父传子 props |
父传子 props |
总结:
父子:1/2/3 |
Props(父子组件通信)父组件可以通过Props将数据传递给子组件。子组件通过props选项声明需要接收的属性,并可以在模板中使用这些属性。父组件通过在子组件标签上绑定属性的方式传递数据给子组件。
子组件
自定义事件(子组件向父组件通信)子组件可以通过触发自定义事件来向父组件通信。父组件可以通过v-on指令监听子组件触发的事件,并在对应的方法中处理数据。 子组件
父组件
Vuex(跨组件通信)Vuex是Vue的官方状态管理库,用于管理应用程序的状态。通过定义全局的状态和在组件中派发(dispatch)和监听(commit)事件,可以实现多个组件之间的通信。Vuex适用于大型应用或需要多个组件共享数据的情况。
其他事件总线、Provide/Inject、订阅/发布模式 |
[vue] vue组件之间的通信都有哪些?
The text was updated successfully, but these errors were encountered: