前端在el-dialog中嵌套多個(gè)el-dialog代碼實(shí)現(xiàn)
一、應(yīng)用場(chǎng)景
- 應(yīng)用場(chǎng)景:需要點(diǎn)擊按鈕后彈出第一層對(duì)話(huà)框,在第一層對(duì)話(huà)框中填寫(xiě)內(nèi)容后,再點(diǎn)擊確認(rèn)彈出第二層對(duì)話(huà)框,且需將第一層填入的內(nèi)容傳遞給第二層,再第二層時(shí)彈出提示,再通過(guò)點(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)容均可寫(xiě)在此處 -->
<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ì)話(huà)框的同時(shí)也關(guān)閉外層的對(duì)話(huà)框
function closeAllDialog() {
// 關(guān)閉內(nèi)層的對(duì)話(huà)框
state.innerVisible = false;
// 關(guān)閉外層的對(duì)話(huà)框
state.outerVisible = false;
}
function saveConfirm() {
// 所勾選的id
const selectedIds = selection.value.map(i => {
return i.id;
});
// 這里寫(xiě)請(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問(wèn)題
?定要?級(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)文章
vue2實(shí)現(xiàn)無(wú)感刷新token的方式詳解
在Web應(yīng)用中,用戶(hù)需要通過(guò)認(rèn)證和授權(quán)才能訪(fǎng)問(wèn)受保護(hù)的資源,為了實(shí)現(xiàn)認(rèn)證和授權(quán)功能,通常需要使用Token來(lái)標(biāo)識(shí)用戶(hù)身份并驗(yàn)證其權(quán)限,本文給大家介紹了vue2實(shí)現(xiàn)無(wú)感刷新token的方式,需要的朋友可以參考下2024-02-02
vue項(xiàng)目如何從session中獲取對(duì)象,并且使用里面的屬性
這篇文章主要介紹了vue項(xiàng)目如何從session中獲取對(duì)象,并且使用里面的屬性問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-12-12
vue2.* element tabs tab-pane 動(dòng)態(tài)加載組件操作
這篇文章主要介紹了vue2.* element tabs tab-pane 動(dòng)態(tài)加載組件操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-07-07
Vue中使用vee-validate表單驗(yàn)證的方法
vee validate 一個(gè)輕量級(jí)的 vue表單驗(yàn)證插件。接下來(lái)通過(guò)本文給大家分享Vue中使用vee-validate表單驗(yàn)證的方法,需要的朋友參考下吧2018-05-05
過(guò)濾器vue.filters的使用方法實(shí)現(xiàn)
這篇文章主要介紹了過(guò)濾器vue.filters的使用方法實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-09-09
將VUE項(xiàng)目部署到服務(wù)器的詳細(xì)步驟
經(jīng)過(guò)一段時(shí)間的探索,前端后端都有大致的樣子了,下面就是部署到服務(wù)器,這篇文章主要給大家介紹了關(guān)于將VUE項(xiàng)目部署到服務(wù)器的詳細(xì)步驟,文中通過(guò)圖文介紹的非常詳細(xì),需要的朋友可以參考下2022-08-08
Vue.js 遞歸組件實(shí)現(xiàn)樹(shù)形菜單(實(shí)例分享)
本文主要對(duì)介紹利用Vue.js 的遞歸組件,實(shí)現(xiàn)了一個(gè)最基本的樹(shù)形菜單。具有很好的參考價(jià)值,下面就跟著小編一起來(lái)看下吧2016-12-12

