Implement modal box in vue (general writing method)
Below I will share with you a general writing recommendation for Vue to implement modal boxes. It has a good reference value and I hope it will be helpful to everyone.
After looking at the source code of the element component, I found that all modal boxes are actually implemented in similar ways, mainly using Vue's two-way binding in componentization. Code:
<!--查看槽点对话框--> <template lang="html"> <transition name="el-fade-in-linear"> <p draggable="true" @drag="mouseDrag" @dragend="mouseDragend" :style="dialogStyle" class="g-dialog-wrapper" v-show="myVisible"> <p class="g-dialog-header"> <p class="left"> 模态框 </p> <p class="right"> <i class="g-times-icon fa fa-times" @click="myVisible=false" aria-hidden="true"></i> </p> </p> <p class="g-dialog-container"> </p> </p> </transition> </template> <script> export default { props: { visible: Boolean }, created() { }, data() { return { myVisible: this.visible, }, computed: {}, methods: { }, components: {}, watch: { myVisible: function (val) { this.$emit('update:visible', val) }, visible: function (val) { this.myVisible = val } } } </script> <style lang="css" scoped> </style>
The main part of the above code is the code in watch to monitor data changes and update in time. So it is very convenient to use it. After registering the component in the component:
<g-key-dialog :visible.sync="keyDialogVisible"></g-key-dialog>
Note: sync must be used here, otherwise it cannot be bound in two directions
above I compiled it for everyone. I hope it will be helpful to everyone in the future.
Related articles:
Solve the problem of vue page refresh or loss of back parameters
Instances of executing functions after leaving the vue page
Usage of vue carousel plug-in vue-concise-slider
The above is the detailed content of Implement modal box in vue (general writing method). For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

If you have recently upgraded to Windows 10 or Windows 11, you may need to download a universal PnP monitor driver on your PC. Therefore, we have come up with a tutorial that will tell you more about Universal PnP Monitor and some quick ways to download and install Universal PnP Drivers on Windows. You may need to download drivers for most monitor brands, including the AcerGenericPnP monitor driver. When looking for monitor types in Device Manager or under the Monitors tab of the display adapter properties, you may notice Generic PnP Monitor. Chances are you'll find it in dual-monitor setups on both laptops and desktops. Down

Introduction to the basic writing and usage of Java callback functions: In Java programming, the callback function is a common programming pattern. Through the callback function, a method can be passed as a parameter to another method, thereby achieving indirect call of the method. The use of callback functions is very common in scenarios such as event-driven, asynchronous programming and interface implementation. This article will introduce the basic writing and usage of Java callback functions, and provide specific code examples. 1. Definition of callback function A callback function is a special function that can be used as a parameter

Detailed explanation of how to write the less than sign in MyBatis MyBatis is an excellent persistence layer framework that is widely used in Java development. In the process of using MyBatis for database operations, we often use the less than sign (

Are you bothered by the annoying watermark in the lower right corner of your Windows 11 screen? You don't know how to delete it? Universal WatermarkDisabler for Windows 11 is a tool that can help remove the annoying watermark in the lower right corner of the Windows screen that interferes with wallpapers and the overall experience. Without further ado, let’s get started. 3 Solutions to Remove Watermark from Windows 11 1. Use Universal Watermark Disabler to Remove Watermark The easiest way to remove evaluation copy watermark in Windows 11 is to use Universal Watermark Disabler, which is a third-party free software

Original title: GraphAlign: EnhancingAccurateFeatureAlignment by Graphmatching for Multi-Modal3DObjectDetection The content that needs to be rewritten is: Paper link: https://arxiv.org/pdf/2310.08261.pdf Author affiliation: Beijing Jiaotong University Hebei University of Science and Technology Tsinghua University Paper idea: LiDAR and cameras are automatic Complementary sensors for 3D object detection in driving. However, studying unnatural interactions between point clouds and images is challenging, and the key lies in how to perform feature alignment of heterogeneous modalities. Currently, many methods simply project

How to write JSP comments There are two types of JSP comments: single-line comments and multi-line comments. Single Line Comments Single line comments end with. The content of the comment is not parsed and therefore does not appear in the output. For example: Multi-line comments Multi-line comments start with /* and end with */. The content of the comment is not parsed and therefore does not appear in the output. For example: /*This is a multi-line comment*/Application scenarios of JSP comments

Requirements In addition to running macOS Monterey 12.3 or newer and iPadOS 15.4 or newer, you'll also need a newer Mac (any 2016 or newer MacBook Pro, or 2018 or newer MacBook Air, Mini, or iMac, or Mac Pro), and newer iPad (any iPad Pro, iPad Air 3rd generation or later, iPad 6th generation or later, iPad Mini 5th generation or later). Any device that wants to use Universal Control needs to be logged into the same Apple ID account that has iCloud enabled. Pass Beta now on M

Microsoft Teams has finally received a version that interacts directly with ARM-based chipsets in the latest Mac PCs. A beta version of Teams optimized for Apple Silicon is available directly from Microsoft. About a year and a half ago, Apple released Mac PCs with its own proprietary chipset. Designed by Apple engineers, the M1 SoC has received a lot of praise. While the previous generation of Apple PCs featured Intel processors, these are based on ARM
