
在vue开发中存在2种通信方式:一种是父子组件通信;另一种是非父子组件通信。下面web建站小编给大家简单介绍一下vue父子组件通信!
父组件template
<template>
<div>
<child @sendMsg="updateMessage"></child>
</div>
</template>
<script>
export default {
data () {
return {
message: ''
}
},
methods: {
updateMessage (msg) {
this.message = msg
}
}
}
</script>
子组件template
<script>
export default {
methods: {
sendMessage () {
this.$emit('sendMsg', 'Hello Vue!')
}
}
}
</script>
上面是“vue如何实现父子组件通信”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_4691.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

华为芯片麒麟和骁龙芯片哪一个更好?什么时候生产的
国家智慧教育平台2.0智能版:新增了白泽智慧学伴/AI智能搜索和AI视频等多项智能化功能
PapersGPT