
vue开发中,如何获取父组件传递的值?下面web建站小编给大家简单介绍一下具体实现代码!
具体代码如下:
<template>
<h2>子组件</h2>
<div @click="sonHander">
我是子组件中的数据
</div>
<h2>使用了props声明接收==>{{ mytitle }}</h2>
<h2>使用参数attrs获取==>{{ attrs.othertitle }}</h2>
</template>
<script>
import { defineComponent,setup } from "vue";
export default defineComponent({
name: "NoCont",
props:{
mytitle:{
type:Object
}
},
setup(props,{attrs,slots,emit}){
function sonHander(){
emit("sonclick","子组件传递给父组件")
}
return {sonHander,attrs}
}
});
</script>
vue全局动态添加meta属性(title,keywords,description)
vue语法中$router和$route有什么不同?附示例代码
上面是“vue语法如何获取父组件传递的值”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_4583.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

Ayoa Ultimate:一款将思维导图、任务管理、项目看板与团队协作融合的全链路生产力平台
el-table表格嵌套v-for循环展示
中国市场监管行政处罚文书网官方首页查询入口
DeepSeek APP
Astronomy Now是英国创办最久的一份线上天文杂志