Vue自定義模態(tài)對(duì)話框彈窗
本文實(shí)例為大家分享了Vue自定義模態(tài)對(duì)話框彈窗的具體代碼,供大家參考,具體內(nèi)容如下
模態(tài)對(duì)話框彈窗效果:
父組件(應(yīng)用頁面)主要代碼:
<template> ? ? <view class="app-container"> ? ? ? ? <modal-dialog showText="確定要取消收藏嗎?" :isShowDialog="isDialog" @cancel="isDialog = false" @confirm="confirmDelete"></modal-dialog> ? ? </view> </template> ? <script> ? ? import modalDialog from '@/components/modalDialog.vue'; ? ?? ? ? export default { ?? ??? ?components:{ ?? ??? ??? ?modalDialog ?? ??? ?}, ?? ??? ?data() { ?? ??? ??? ?return { ?? ??? ??? ??? ?isDialog: false, ?? ??? ??? ?} ?? ??? ?}, ? ? ? ? methods: { ? ? ? ? ? ? // 業(yè)務(wù)代碼...... ? ? ? ? ? ? this.isDialog = false; ? ? ? ? } ?? ?} </script>
子組件(自定義組件)代碼:
<template> ?? ?<view> ?? ??? ?<view class="global-mask" v-show="isShowDialog"></view> ?? ??? ?<view class="global-dialog" v-show="isShowDialog" style="top: 45%;"> ?? ??? ??? ?<view class="title">溫馨提示</view> ?? ??? ??? ?<view class="content"> ?? ??? ??? ??? ?<view class="text">{{showText}}</view> ?? ??? ??? ?</view> ?? ??? ??? ?<view class="btn"> ?? ??? ??? ??? ?<view class="left" @tap="cancel" v-if="isShowCancel">{{cancelText}}</view> ?? ??? ??? ??? ?<view class="right" @tap="confirm" v-if="isShowConfirm">{{confirmText}}</view> ?? ??? ??? ?</view> ?? ??? ?</view> ?? ?</view> </template> ? <script> ?? ?export default { ?? ??? ?name: 'modalDialog', ?? ??? ?props: { ?? ??? ??? ?showText: { ?? ??? ??? ??? ?type: String, ?? ??? ??? ??? ?default: '提示內(nèi)容' ?? ??? ??? ?}, ?? ??? ??? ?isShowDialog: { ?? ??? ??? ??? ?type: Boolean, ?? ??? ??? ??? ?default: false ?? ??? ??? ?}, ?? ??? ??? ?isShowCancel: { ?? ??? ??? ??? ?type: Boolean, ?? ??? ??? ??? ?default: true ?? ??? ??? ?}, ?? ??? ??? ?cancelText: { ?? ??? ??? ??? ?type: String, ?? ??? ??? ??? ?default: '取消' ?? ??? ??? ?}, ?? ??? ??? ?isShowConfirm: { ?? ??? ??? ??? ?type: Boolean, ?? ??? ??? ??? ?default: true ?? ??? ??? ?}, ?? ??? ??? ?confirmText: { ?? ??? ??? ??? ?type: String, ?? ??? ??? ??? ?default: '確定' ?? ??? ??? ?} ?? ??? ?}, ?? ??? ?data() { ?? ??? ??? ?return { ?? ??? ??? ??? ? ?? ??? ??? ?}; ?? ??? ?}, ?? ??? ?methods: { ?? ??? ??? ?cancel() { ?? ??? ??? ??? ?this.$emit('cancel'); ?? ??? ??? ?}, ?? ??? ??? ? ?? ??? ??? ?confirm() { ?? ??? ??? ??? ?this.$emit('confirm'); ?? ??? ??? ?} ?? ??? ?} ?? ?} </script> ? <style lang="scss"> ? ? .global-mask { ?? ??? ?position: fixed; ?? ??? ?top: 0; ?? ??? ?left: 0; ?? ??? ?z-index: 998; ?? ??? ?width: 100%; ?? ??? ?height: 100%; ?? ??? ?background: rgba($color: #000000, $alpha: 0.3); ?? ?} ?? ?.global-dialog { ?? ??? ?position: fixed; ?? ??? ?top: 500rpx; ?? ??? ?left: 60rpx; ? ? ? ? top: 45%; ?? ??? ?z-index: 999; ?? ??? ?width: 630rpx; ?? ??? ?background: #FFFFFF; ?? ??? ?border-radius: 15rpx; ?? ??? ?overflow: hidden; ?? ??? ?.title { ?? ??? ??? ?font-size: 36rpx; ?? ??? ??? ?font-weight: 500; ?? ??? ??? ?text-align: center; ?? ??? ??? ?line-height: 100rpx; ?? ??? ??? ?padding-bottom: 10rpx; ?? ??? ?} ?? ??? ?.content { ?? ??? ??? ?.text { ?? ??? ??? ??? ?font-size: 32rpx; ?? ??? ??? ??? ?text-align: center; ?? ??? ??? ??? ?padding-bottom: 40rpx; ?? ??? ??? ?} ?? ??? ??? ?.form { ?? ??? ??? ??? ?padding: 0 40rpx; ?? ??? ??? ??? ?.item { ?? ??? ??? ??? ??? ?display: flex; ?? ??? ??? ??? ??? ?align-items: center; ?? ??? ??? ??? ??? ?justify-content: space-between; ?? ??? ??? ??? ??? ?margin-bottom: 40rpx; ?? ??? ??? ??? ??? ?input { ?? ??? ??? ??? ??? ??? ?width: 340rpx; ?? ??? ??? ??? ??? ??? ?height: 60rpx; ?? ??? ??? ??? ??? ??? ?border: 1px solid #eaeaea; ?? ??? ??? ??? ??? ??? ?border-radius: 10rpx; ?? ??? ??? ??? ??? ??? ?padding: 0 20rpx; ?? ??? ??? ??? ??? ?} ?? ??? ??? ??? ?} ?? ??? ??? ?} ?? ??? ?} ?? ??? ?.btn { ?? ??? ??? ?border-top: 1px solid #eaeaea; ?? ??? ??? ?display: flex; ?? ??? ??? ?&> view { ?? ??? ??? ??? ?flex: 1; ?? ??? ??? ??? ?text-align: center; ?? ??? ??? ??? ?line-height: 100rpx; ?? ??? ??? ??? ?font-size: 32rpx; ?? ??? ??? ??? ?&.left { ?? ??? ??? ??? ??? ?color: #666666; ?? ??? ??? ??? ?} ?? ??? ??? ??? ?&.right { ?? ??? ??? ??? ??? ?color: #FFFFFF; ?? ??? ??? ??? ??? ?background: #FF3F42; ?? ??? ??? ??? ?} ?? ??? ??? ?} ?? ??? ?} ?? ?} </style>
以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Vue3+Koa2實(shí)現(xiàn)圖片上傳功能的示例代碼
這篇文章主要為大家詳細(xì)介紹了如何使用Vue3和Koa2實(shí)現(xiàn)圖片上傳功能,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2024-02-02vue根據(jù)權(quán)限動(dòng)態(tài)渲染按鈕、組件等的函數(shù)式組件實(shí)現(xiàn)
這篇文章主要介紹了vue根據(jù)權(quán)限動(dòng)態(tài)渲染按鈕、組件等的函數(shù)式組件實(shí)現(xiàn)方式,具有很好的參考價(jià)值,希望杜大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-11-11vue?watch中如何獲取this.$refs.xxx節(jié)點(diǎn)
這篇文章主要介紹了vue?watch中獲取this.$refs.xxx節(jié)點(diǎn)的方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-08-08使用Vue3+ElementPlus前端實(shí)現(xiàn)分片上傳的全過程
ElementPlus是一套為開發(fā)者、設(shè)計(jì)師和產(chǎn)品經(jīng)理準(zhǔn)備的基于Vue?3.0的組件庫,提供了配套設(shè)計(jì)資源,幫助你的網(wǎng)站快速成型,下面這篇文章主要給大家介紹了關(guān)于使用Vue3+ElementPlus前端實(shí)現(xiàn)分片上傳的相關(guān)資料,需要的朋友可以參考下2022-11-11vue 中 beforeRouteEnter 死循環(huán)的問題
這篇文章主要介紹了vue beforeRouteEnter 死循環(huán)的問題,在文章末尾給大家補(bǔ)充介紹了vue中beforeRouteEnter使用的誤區(qū),需要的朋友可以參考下2019-04-04vue插件--仿微信小程序showModel實(shí)現(xiàn)模態(tài)提示窗功能
這篇文章主要介紹了vue插件--仿微信小程序showModel實(shí)現(xiàn)模態(tài)提示窗,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-08-08vite配置@別名以及讓vscode智能提示路經(jīng)的步驟
這篇文章主要給大家介紹了關(guān)于vite配置@別名以及讓vscode智能提示路經(jīng)的步驟,文中通過代碼示例以及圖文介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用vue具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2023-08-08VUE+elementui面包屑實(shí)現(xiàn)動(dòng)態(tài)路由詳解
今天小編就為大家分享一篇VUE+elementui面包屑實(shí)現(xiàn)動(dòng)態(tài)路由詳解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-11-11Vue.js仿Metronic高級(jí)表格(一)靜態(tài)設(shè)計(jì)
這篇文章主要為大家詳細(xì)介紹了Vue.js仿Metronic高級(jí)表格的靜態(tài)設(shè)計(jì),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-04-04