
在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,我们会在看到邮件的第一时间内为您处理!

wordpress如何实现不同页面显示不同评论模板
海豚AI学APP最新版
EasyAnnounce官网使用入口,精准解决人工播报不统一、AI语音助手误读生僻姓名等行业痛点
MUUUUU:一个来自日本的高质量垂直网站设计作品平台