从另一个文件调用模态窗口

问题描述 投票:0回答:1
javascript vue.js nuxt.js vue-component
1个回答
0
投票

您可以通过在子元素中发出来调用它

在你的元素中添加 @click="isOpen = true; newquery 像这样

<button class="header_button" @click="newquery" >
const emit = defineEmits(['openmymodal'])
function newquery(new_value = "close_modal"){
 emit ('openmymodal',new_value)
}

并且在您的父元素中您应该添加

<MazDialog v-model="isOpen" title="Dialog Title" @openmymodal="dothisfunction">


<script setup>
const dothisfunction= (new_value) =>{
    isOpen.value = false
}
© www.soinside.com 2019 - 2024. All rights reserved.