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

Nginx如何利用proxy_cache模块实现动态缓存
影响关键词排名的因素有哪些?
Meeseeks模型:已在魔搭社区、GitHub、Huggingface上线(附链接)
一款支持100多种语言,快速生成语音和视频内容的AI文本转语音平台——Narakeet