前端在el-dialog中嵌套多個(gè)el-dialog代碼實(shí)現(xiàn)
一、應(yīng)用場(chǎng)景
- 應(yīng)用場(chǎng)景:需要點(diǎn)擊按鈕后彈出第一層對(duì)話框,在第一層對(duì)話框中填寫內(nèi)容后,再點(diǎn)擊確認(rèn)彈出第二層對(duì)話框,且需將第一層填入的內(nèi)容傳遞給第二層,再第二層時(shí)彈出提示,再通過點(diǎn)擊第二層的確認(rèn)按鈕進(jìn)行請(qǐng)求接口,將第一層的內(nèi)容 傳遞給后端



二、代碼實(shí)現(xiàn)
<template>
<table>
<template #action>
<el-button type="success" @click="outerVisible = true">
修改備注
</el-button>
</template>
</table>
<el-dialog v-model="outerVisible" title="提示" draggable width="520px">
<!-- #default:自定義內(nèi)容均可寫在此處 -->
<template #default>
<!-- 這里的el-form是外層dialog中的表單 -->
<el-form label-width="100px" :model="note">
<el-form-item label="備注" prop="note">
<el-input v-model="note" />
</el-form-item>
</el-form>
<!-- 內(nèi)嵌的dialog -->
<el-dialog
v-model="innerVisible"
width="30%"
title="提示"
append-to-body
draggable
>
<span>請(qǐng)確認(rèn)是否發(fā)送數(shù)據(jù)?</span>
<template #footer>
<div class="dialog-footer">
<el-button @click="closeAllDialog">關(guān)閉</el-button>
<el-button type="primary" @click="saveConfirm"> 確認(rèn) </el-button>
</div>
</template>
</el-dialog>
</template>
<template #footer>
<div class="dialog-footer">
<el-button @click="outerVisible = false">{{
t('global.action.close')
}}</el-button>
<el-button type="primary" @click="innerVisible = true">
{{ t('global.action.confirm') }}
</el-button>
</div>
</template>
</el-dialog>
</template>
<script lang="ts">
import { defineComponent, reactive } from 'vue';
import { Data, sendData } from '@/services/listData';
interface ViewState {
selectedOrders: Data[];
note: string;
outerVisible: boolean;
innerVisible: boolean;
}
export default defineComponent({
name: 'list',
components: {},
setup() {
const state = reactive<ViewState>({
note: '',
outerVisible: false,
innerVisible: false,
});
// 關(guān)閉內(nèi)層對(duì)話框的同時(shí)也關(guān)閉外層的對(duì)話框
function closeAllDialog() {
// 關(guān)閉內(nèi)層的對(duì)話框
state.innerVisible = false;
// 關(guān)閉外層的對(duì)話框
state.outerVisible = false;
}
function saveConfirm() {
// 所勾選的id
const selectedIds = selection.value.map(i => {
return i.id;
});
// 這里寫請(qǐng)求接口的邏輯
sendData(selectedIds, state.note)
.then(() => {
ElMessage({
type: 'success',
message: '發(fā)送成功',
});
})
.finally(() => {
state.innerVisible = false;
state.outerVisible = false;
});
}
return {
...toRefs(state),
saveConfirm,
closeAllDialog,
};
},
});
</script>
<style scoped lang="scss"></style>附:el-dialog嵌套el-dialog問題
?定要?級(jí) el-dialog :modal-append-to-body=“false”
?級(jí) el-dialog 同時(shí)加上 :append-to-body=“true”
含義:
- modal-append-to-body 遮罩層是否插?? body 元素上,若為 false,則遮罩層會(huì)插?? Dialog的?元素上
- append-to-body Dialog ?身是否插?? body 元素上。嵌套的 Dialog 必須指定定該屬性并賦值為true
總結(jié)
到此這篇關(guān)于前端在el-dialog中嵌套多個(gè)el-dialog的文章就介紹到這了,更多相關(guān)前端嵌套多個(gè)el-dialog內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Element-ui table中過濾條件變更表格內(nèi)容的方法
下面小編就為大家分享一篇Element-ui table中過濾條件變更表格內(nèi)容的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-03-03
vue3:vue2中protoType更改為config.globalProperties問題
這篇文章主要介紹了vue3:vue2中protoType更改為config.globalProperties問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-09-09
Vue中Axios配置不同的baseURL,請(qǐng)求不同的域名接口方式
這篇文章主要介紹了Vue中Axios配置不同的baseURL,請(qǐng)求不同的域名接口方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-07-07
一文詳解Vue3中使用ref獲取元素節(jié)點(diǎn)
這篇文章主要介紹了一文詳解Vue3中使用ref獲取元素節(jié)點(diǎn),本文介紹在vue3的setup中使用composition?API獲取元素節(jié)點(diǎn)的幾種方法,需要的朋友可以參考一下2022-07-07
vue3使用別名報(bào)錯(cuò)問題的解決辦法(vetur插件報(bào)錯(cuò)問題)
最近在寫一個(gè)購物網(wǎng)站使用vue,使用中遇到了問題,下面這篇文章主要給大家介紹了關(guān)于vue3使用別名報(bào)錯(cuò)問題的解決辦法,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-07-07
Vue?socket.io模塊實(shí)現(xiàn)聊天室流程詳解
vue-socket.io其實(shí)是在socket.io-client(在瀏覽器和服務(wù)器之間實(shí)現(xiàn)實(shí)時(shí)、雙向和基于事件的通信)基礎(chǔ)上做了一層封裝,將socket掛載到vue實(shí)例上,同時(shí)可使用sockets對(duì)象輕松實(shí)現(xiàn)組件化的事件監(jiān)聽,在vue項(xiàng)目中使用起來更方便2022-12-12
vue實(shí)現(xiàn)el-menu和el-tab聯(lián)動(dòng)的示例代碼
本文主要介紹了vue實(shí)現(xiàn)el-menu和el-tab聯(lián)動(dòng)的示例代碼,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-04-04
簡(jiǎn)述vue-cli中chainWebpack的使用方法
今天就主要來講一下在vue.config.js中對(duì)一些配置的更改,簡(jiǎn)單介紹一下loader的使用;用configureWebpack簡(jiǎn)單的配置;用chainWebpack做高級(jí)配置;包括對(duì)loader的添加,修改;以及插件的配置,需要的朋友可以參考下2019-07-07

