This article example shares the specific code of vue custom pop-up effect for your reference. The specific content is as follows 1. Customize confirmation boxes and prompt boxesDetermine whether it is a confirmation box or a prompt box based on the type passed in <template> <transition name="confirm-fade"> <div v-if="isShowConfirm" class="my-confirm" @click.stop="clickFun('clickCancel')"> <div class="confirm-content-wrap" @click.stop> <h3 class="my-confirm-title" v-show="titleText != ''">{{ titleText }}</h3> <p class="my-confirm-content">{{ content }}</p> <div class="my-operation"> <div v-if="type==='confirm'" class="my-cancel-btn" @click="clickFun('clickCancel')"> <p class="my-btn-text my-border-right">{{ cancelText }}</p> </div> <div class="confirm-btn" @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, // Used to control the display/hide of the entire window titleText: 'Operation Tips', // Prompt box title content: 'Say Something ...', // Prompt box content cancelText: 'Cancel', // Cancel button text confirmText: 'Confirm', // Confirm button text type: 'confirm', // Indicates the type of pop-up box: confirm - confirmation pop-up window (with cancel button); alert - notification pop-up box (without cancel button) outerData: null // Used to record data transmitted from the outside, and can also be used to monitor userBehavior and event functions to determine which event was triggered.} }, methods: { show (content, config) { this.content = content || 'Say Something ...' if (Object.prototype.toString.call(config) === '[object Object]') { // Make sure the user passes an object this.titleText = config.titleText || '' this.cancelText = config.cancelText || 'Cancel' this.confirmText = config.confirmText || 'Confirm' this.type = config.type || 'confirm' this.outerData = config.data || null } this.isShowConfirm = true }, hidden () { this.isShowConfirm = false this.titleText = 'Operation Tips' this.cancelText = 'Cancel' this.confirmText = 'Confirm' 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; /* This prevents the black background from appearing when the user long presses the screen, and the font scaling problem when the iPhone is horizontal and flat*/ -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } /*Enter and exit animations*/ .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; } /* Wrapping layer container style */ .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; } /* Top title section */ .my-confirm-title { padding-top: 20px; text-align: center; font-size: 20px; font-weight: 500; color: #333; } /* Middle content part*/ .my-confirm-content { padding: 0 15px; padding-top: 20px; margin-bottom: 32px; text-align: center; font-size: 16px; color: #666; line-height: 1.5; } /* Bottom button style */ .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; } /* Other decoration styles*/ .my-border-right { border-right: 1px solid #eee; } /* Incoming animation*/ @keyframes opacity { 0% { opacity: 0; } 100% { opacity: 1; } } @keyframes scale { 0% { transform: scale(0); } 60% { transform: scale(1.1); } 100% { transform: scale(1); } } /* Exit animation */ @keyframes outOpacity { 0% { opacity: 1; } 100% { opacity: 0; } } </style> 2. Call:(1) Use of prompt box: <DialogView ref="myDialog" @userBehavior="changeData"></DialogView> … //prompt box this.$refs.myDialog.show(content, { type: 'alert', confirmText: 'OK', cancelText: 'Cancel', titleText: '', data: null }) Effect: (2) Confirmation box: this.$refs.myDialog.show('Do you want to redeem this product?', { type: 'confirm', confirmText: 'Exchange now', cancelText: 'No thanks', titleText: '', data: {shop: shop, operate: 'exchange'} }) Effect: When the confirmation box is pressed: 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 } } }, The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
>>: CentOS 8 officially released based on Red Hat Enterprise Linux 8
This article shares the encapsulation code of Jav...
Table of contents 1. The default focus is on the ...
Preface This article will explain how Vue compone...
When uploading on some websites, after clicking t...
Below, we introduce three ways to draw heart shap...
<br />Original source: http://www.a-xuan.cn/...
Install virtualization software Before installing...
Table of contents 1. What is 2. Use Numeric Enume...
Table of contents 1. Current situation 2. Communi...
Table of contents What is Routing Basic use of pu...
This article example shares the specific code of ...
Result:Implementation code: html <link href=...
1. MySQL transaction concept MySQL transactions a...
Find the problem When retrieving the top SQL stat...
First, pull the image (or just create a container...