当前位置:网站首页>父组件访问子组件的方法或参数 (子组件暴漏出方法defineExpose)
父组件访问子组件的方法或参数 (子组件暴漏出方法defineExpose)
2022-07-26 12:45:00 【@小朱呀路】
父组件
<template>
<div>
<Menu ref="menus" @onclick3="getList3"/>
</div>
</template>
<script setup lang="ts">
import {
reactive ,ref} from 'vue'
const menus=ref(null) //const的名字要和ref定义的一致
interface jianc{
title:string
}
const getList3=()=>{
//拿的ref子组件下的参数list [6,6,6,6] //
console.log(menus.value.list.map(v=>v))
}
</script>
<style scoped>
</style>
子组件 (子组件emit提交一个自定义事件 父组件触发之后 拿到ref子组件下的参数list[6,6,6,6])
<template>
<div class="">
<button @click="clickTap3">派发3</button>
</div>
</template>
<script setup lang="ts">
import {
reactive, defineEmits, defineExpose} from 'vue';
const list=reactive<number[]>([6,6,6,6])//number类型的数组值为[6,6,6,6]
const emit=defineEmits(['onclick3']);
const onclick3=()=>{
emit('onclick3')
}
// 子组件派出去([6,6,6,6]) 父组件拿
defineExpose({
list
})
</script>
<style scoped>
.menu{
width: 100px;text-align: center;
border: 1px solid #000;
height: 100vh;
}
</style>
边栏推荐
- Example of establishing socket communication with Siemens PLC based on C # open TCP communication
- The database consists of stored procedures and functions
- New function | intelligent open search online customized word weight model
- What is the Internet of things? The most comprehensive explanation of common IOT protocols
- Transformer dominates the world? Depth wise conv has something to say
- Tencent cloud and smart industry business group (CSIG) adjusted the organizational structure and established the digital twin product department
- Version of NDK matched the requested version 21.0.6113669. versions available locally: 2
- Slam 02. overall framework
- Flutter dart generates a list of random numbers that are not repeated in n intervals
- V00 - do whatever you want when you are old
猜你喜欢

Knowledge points of C language documents

Example of establishing socket communication with Siemens PLC based on C # open TCP communication

Paper reading MLPD: multi label pedestrian detector in multispectral domain (Internship Program of Hikvision Research Institute)

UE5 官方案例Lyra 全特性详解 7.资源管理

Food safety | are sterile eggs really completely sterile?

Today in history: IBM obtained the first patent; Verizon acquires Yahoo; Amazon releases fire phone

论文阅读-MLPD:Multi-Label Pedestrian Detector in Multispectral Domain(海康威视研究院实习项目)

The best engineer was "forced" away by you like this!

Microsoft has shut down two attack methods: Office macro and RDP brute force cracking

From January to June, China's ADAS suppliers accounted for 9%, and another parts giant comprehensively laid out the new smart drive track
随机推荐
New function | intelligent open search online customized word weight model
Various extensions of hcip-9.ospf
Backtracking - question 51 Queen n -- a classic backtracking problem that must be overcome
Code examples explain the difference between [reentrant lock] and [non reentrant lock]?
Visual stdio(VS)中的(int argc、char** argv)命令行参数
Food safety | what food can be heated in a microwave oven? You should know these potential safety hazards
Shell variables and references
The best engineer was "forced" away by you like this!
论文阅读-MLPD:Multi-Label Pedestrian Detector in Multispectral Domain(海康威视研究院实习项目)
Router. Push(), router. Reply(), router. Go()
关于图片地址链接复制问题
Sword finger offer 24. reverse the linked list
mqtt send receive
0基础编程资源大全(先收藏~慢慢看~)
基于C#开放式TCP通信建立与西门子PLC的socket通信示例
How to optimize a large number of if else [email protected] Detailed explanation of valib
Kubernetes---- installing and deploying NFS servers
What is a callback function? Understanding of the word "back"
0 basic programming resources (collect first ~ read slowly ~)
华为超融合FusionCube解决方案笔记