当前位置:网站首页>The parent component accesses the methods or parameters of the child component (the child component exposes the method defineexpose)
The parent component accesses the methods or parameters of the child component (the child component exposes the method defineexpose)
2022-07-26 13:04:00 【@Little Zhu Yalu】
Parent component
<template>
<div>
<Menu ref="menus" @onclick3="getList3"/>
</div>
</template>
<script setup lang="ts">
import {
reactive ,ref} from 'vue'
const menus=ref(null) //const The name of the ref Consistency of definition
interface jianc{
title:string
}
const getList3=()=>{
// Taken ref Parameters under sub components list [6,6,6,6] //
console.log(menus.value.list.map(v=>v))
}
</script>
<style scoped>
</style>
Child components ( Child components emit Submit a custom event After the parent component is triggered Get ref Parameters under sub components list[6,6,6,6])
<template>
<div class="">
<button @click="clickTap3"> distributed 3</button>
</div>
</template>
<script setup lang="ts">
import {
reactive, defineEmits, defineExpose} from 'vue';
const list=reactive<number[]>([6,6,6,6])//number The array value of type is [6,6,6,6]
const emit=defineEmits(['onclick3']);
const onclick3=()=>{
emit('onclick3')
}
// Send out the sub components ([6,6,6,6]) Parent component takes
defineExpose({
list
})
</script>
<style scoped>
.menu{
width: 100px;text-align: center;
border: 1px solid #000;
height: 100vh;
}
</style>
边栏推荐
- 食品安全 | 无菌蛋真的完全无菌吗?
- Azure synapse analytics Performance Optimization Guide (2) -- optimize performance using materialized views (Part 1)
- Kubernetes----安装部署NFS服务器
- Solution: unable to load the file c:\users\user\appdata\roaming\npm\npx PS1, because running scripts is prohibited on this system.
- Sword finger offer (21): push in and pop-up sequence of stack
- 关于图片地址链接复制问题
- Various extensions of hcip-9.ospf
- How to remove underline and color when there is focus in the shutter textfield
- The "2022 Huawei developer competition eastern China division opening ceremony" was successfully held in Fuzhou
- Streamnational team culture: a "transparent" company
猜你喜欢

(int argc, char** argv) command line parameters in visual stdio (VS)

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

Ue5 official case Lyra full feature explanation 7. resource management

Vs code set the method of ctrl+s saving and automatic formatting

Sword finger offer 24. reverse the linked list

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

Kuzaobao: summary of Web3 encryption industry news on July 25

PXE原理与配置

食品安全 | 无菌蛋真的完全无菌吗?

Today's sleep quality record 75 points
随机推荐
父组件访问子组件的方法或参数 (子组件暴漏出方法defineExpose)
Food safety | can you eat any fruit?
After being fined "paid leave" for one month, Google fired him who "loves" AI
1-6月中国ADAS供应商占比9% 又一家零部件巨头全面布局智驾新赛道
基于ASP.NET的某高校学院档案管理系统
PXE原理与配置
Transformer dominates the world? Depth wise conv has something to say
A super easy-to-use artifact apifox, throw swagger a few streets... (glory Collection Edition)
Removable tablespace
2022 employment season! Adobe helps creative industry workers break through the shackles of skills and return to the source of ability
(int argc, char** argv) command line parameters in visual stdio (VS)
Database composition table
Detailed explanation of redis's single login
Flutter integrated Aurora push
[applet] why can't the onreachbottom event be triggered? (one second)
Huawei ultra fusion fusioncube solution notes
LCD笔记(7)LCD驱动程序框架_配置时钟
数据库组成视图
关于图片地址链接复制问题
Code error reporting and problem solving experience II: test error reporting in yolov5