国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術文章
文章詳情頁

vue自定義彈框效果(確認框、提示框)

瀏覽:4日期:2022-09-29 10:23:34

本文實例為大家分享了vue自定義彈框效果的具體代碼,供大家參考,具體內(nèi)容如下

1、自定義確認框和提示框

根據(jù)傳入的type來判斷是確認框或提示框

<template> <transition name='confirm-fade'> <div v-if='isShowConfirm' @click.stop='clickFun(’clickCancel’)'> <div @click.stop><h3 v-show='titleText != ’’'>{{ titleText }}</h3><p class='my-confirm-content'>{{ content }}</p><div class='my-operation'> <div v-if='type===’confirm’' @click='clickFun(’clickCancel’)'> <p class='my-btn-text my-border-right'>{{ cancelText }}</p> </div> <div @click='clickFun(’clickConfirm’)'> <p class='my-btn-text'>{{ confirmText }}</p> </div></div> </div> </div> </transition></template> <script type='text/ecmascript-6'>export default { data () { return { isShowConfirm: false, // 用于控制整個窗口的顯示/隱藏 titleText: ’操作提示’, // 提示框標題 content: ’Say Something ...’, // 提示框的內(nèi)容 cancelText: ’取消’, // 取消按鈕的文字 confirmText: ’確認’, // 確認按鈕的文字 type: ’confirm’, // 表明彈框的類型:confirm - 確認彈窗(有取消按鈕);alert - 通知彈框(沒有取消按鈕) outerData: null // 用于記錄外部傳進來的數(shù)據(jù),也可以給外部監(jiān)聽userBehavior,事件的函數(shù)提供判斷到底是哪個事件觸發(fā)的 } }, methods: { show (content, config) { this.content = content || ’Say Something ...’ if (Object.prototype.toString.call(config) === ’[object Object]’) {// 確保用戶傳遞的是一個對象this.titleText = config.titleText || ’’this.cancelText = config.cancelText || ’取消’this.confirmText = config.confirmText || ’確認’this.type = config.type || ’confirm’this.outerData = config.data || null } this.isShowConfirm = true }, hidden () { this.isShowConfirm = false this.titleText = ’操作提示’ this.cancelText = ’取消’ this.confirmText = ’確認’ this.type = ’confirm’ this.outerData = null }, clickFun (type) { this.$emit(’userBehavior’, type, this.outerData) this.hidden() } }}</script> <style scoped>.my-confirm { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0, 0, 0, 0.5); z-index: 998; /* 這里防止當用戶長按屏幕,出現(xiàn)的黑色背景色塊,以及 iPhone 橫平時字體的縮放問題 */ -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);} /* 進入和出去的動畫 */.confirm-fade-enter-active { animation: opacity 0.3s;}.confirm-fade-enter-active .confirm-content-wrap { animation: scale 0.3s;}.confirm-fade-leave-active { animation: outOpacity 0.2s;} /* 包裹層容器樣式 */.confirm-content-wrap { position: absolute; top: 28%; left: 0; right: 0; width: 280px; margin: 0 auto; background-color: #fff; border-radius: 5px; z-index: 999; user-select: none;} /* 頂部標題部分 */.my-confirm-title { padding-top: 20px; text-align: center; font-size: 20px; font-weight: 500; color: #333;} /* 中間內(nèi)容部分 */.my-confirm-content { padding: 0 15px; padding-top: 20px; margin-bottom: 32px; text-align: center; font-size: 16px; color: #666; line-height: 1.5;} /* 底部按鈕樣式 */.my-operation { display: flex; border-top: 1px solid #eee;}.my-operation .my-cancel-btn, .confirm-btn { flex: 1;}.my-operation .confirm-btn { color: #ffb000;}.my-operation .my-btn-text { text-align: center; font-size: 16px; margin: 8px 0; padding: 6px 0;} /* 其他修飾樣式 */.my-border-right { border-right: 1px solid #eee;} /* 進來的動畫 */@keyframes opacity { 0% { opacity: 0; } 100% { opacity: 1; }}@keyframes scale { 0% { transform: scale(0); } 60% { transform: scale(1.1); } 100% { transform: scale(1); }} /* 出去的動畫 */@keyframes outOpacity { 0% { opacity: 1; } 100% { opacity: 0; }}</style>2、調(diào)用:

(1)提示框的使用:

<DialogView ref='myDialog' @userBehavior='changeData'></DialogView>……//提示框this.$refs.myDialog.show(content, {type: ’alert’,confirmText: ’OK’,cancelText: ’取消’,titleText: ’’,data: null })

效果:

vue自定義彈框效果(確認框、提示框)

(2)確認框:

this.$refs.myDialog.show(’要兌換這個商品么?’, { type: ’confirm’, confirmText: ’立即兌換’, cancelText: ’不用了’, titleText: ’’, data: {shop: shop, operate: ’exchange’} })

效果:

vue自定義彈框效果(確認框、提示框)

當為確認框時的按鍵處理:changeData

<DialogView ref='myDialog' @userBehavior='changeData'></DialogView> …… changeData (type, data) { console.log(’changeData’,data) if (type === ’clickConfirm’) {if (data.operate === ’exchange’) { // this.reduceEnergy(data.shop) this.exchangeCoupon(data.shop)} else if (data.operate === ’downLoad’) { window.location = data.url} else if (data.operate === ’login’) { this.uplusApi.upVdnModule.goToPage({url: ’mpaas://usercenter’}) this.isLogin = false} }},

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標簽: Vue
相關文章:
主站蜘蛛池模板: 欧美成人综合在线 | 免费一级特黄欧美大片勹久久网 | 99精彩视频| 午夜爽爽爽 | 欧美一级美片在线观看免费 | 韩国三级 mp4 | 亚洲综合日韩精品欧美综合区 | 国产免费高清福利拍拍拍 | 免费 视频 1级 | 欧美成人交tv免费观看 | 久久久久久久久网站 | 久久aⅴ免费观看 | 亚洲视频二 | 精品一区二区三区在线视频观看 | 欧美视频精品 | 亚洲国产成人私人影院 | 日本久久久久久 | 久久精品欧美日韩精品 | 中文字幕亚洲一区 | 一区二区三区国产精品 | 美国一级毛片∞ | 欧美精品日日鲁夜夜添 | 亚洲精品美女在线观看播放 | 中文精品99久久国产 | 日本成本人视频 | 在线看欧美日韩中文字幕 | 精品欧美一区二区三区四区 | 国产成人精品男人免费 | 欧美日韩综合网在线观看 | 99精品国产高清一区二区三区香蕉 | 韩国毛片 | 欧美一级特黄aa大片视频 | 一区二区中文字幕亚洲精品 | 美女黄色在线 | cao在线观看 | 国产一级淫片a免费播放口之 | 国产亚洲精品资源一区 | 欧美日韩成人在线视频 | 国产一区二区在线免费观看 | 久草在线| 又黄又爽又刺激的视频 |