vue3语法中setup函数的props和context参数怎么运用,下面web建站小编给大家简单介绍一下具体实现代码!
父组件
<template>
<div>
父组件
</div>
<no-cont :mytitle="msg"
othertitle="其它的标题"
@sonclick="sonclick">
</no-cont>
</template>
<script>
import NoCont from "../components/NoCont.vue"
export default {
setup () {
let msg={
title:"父组件给子给子组件的数据"
}
function sonclick(msss:string){
console.log(msss)
}
return {msg,sonclick}
},
components:{
NoCont
}
}
</script>
子组件
<template>
<div @click="sonHander">
我是子组件中的数据
</div>
</template>
<script>
import { defineComponent,setup } from "vue";
export default defineComponent({
name: "NoCont",
setup(props,context){
console.log("props==>",props.mytitle);//输出的值是 undefined
function sonHander(){
context.emit("sonclick","子组件传递给父组件")
}
return {sonHander}
}
});
</script>
上面是“vue3语法中setup函数的props和context参数怎么用”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_4581.html
workflows工作流
一位穿着优雅银色装饰黑色连衣裙的苗条模特
穿着蘑菇帽的小蚂蚁探险家ComfyUI工作流
海中一头鲸鱼ComfyUI工作流
树上挂着一只快乐的小樱桃
一只放屁虫甲虫ComfyUI工作流
奇幻绘画风格:一只巨大蜗牛ComfyUI工作流
梦幻中的一只猫咪ComfyUI工作流
泰坦尼克号桌面壁纸上ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

js导出excel插件(兼容mac电脑Numbers表格)
纯html+css做一个3d统计效果
利用html5+css3实现滚雪球效果(附代码)
制作一个好玩的倒计时
利用CSS3做一个星级评分样式
js实现下雪特效
用ascii字符画图像
canvas黑洞漩涡(canvas+js)







