vue语法如何获取父组件传递的值
vue开发中,如何获取父组件传递的值?下面编程教程网小编给大家简单介绍一下具体实现代码!
具体代码如下:
<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语法如何获取父组件传递的值”的全面内容,想了解更多关于 vuejs 内容,请继续关注编程基础学习网。