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!

如果您最近升级到Windows10或Windows11,您可能需要在您的PC上下载通用PnP显示器驱动程序。因此,我们想出了一个教程,它将告诉您更多关于通用PnP监视器和一些在Windows上下载和安装通用PnP驱动程序的快速方法。您可能需要下载大多数显示器品牌的驱动程序,包括AcerGenericPnP显示器驱动程序。在设备管理器或显示适配器属性的监视器选项卡下查找监视器类型时,您可能会注意到通用PnP监视器。有机会在笔记本电脑和台式机的双显示器设置中找到它。下

Java回调函数的基本写法和使用方法引言:在Java编程中,回调函数是一种常见的编程模式,通过回调函数,可以将某个方法作为参数传递给另一个方法,从而实现方法的间接调用。回调函数的使用,在事件驱动、异步编程和接口实现等场景中非常常见。本文将介绍Java回调函数的基本写法和使用方法,并提供具体的代码示例。一、回调函数的定义回调函数是一种特殊的函数,它可以作为参数

MyBatis中小于号的写法详解MyBatis是一个优秀的持久层框架,广泛应用于Java开发中。在使用MyBatis进行数据库操作的过程中,我们经常会用到小于号(

您是否对Windows11屏幕右下角的恼人水印感到困扰?你不知道如何删除它?适用于Windows11的UniversalWatermarkDisabler是一种工具,可以帮助删除Windows屏幕右下角干扰壁纸和整体体验的烦人水印。事不宜迟,让我们开始吧。从Windows11中删除水印的3种解决方案1.使用UniversalWatermarkDisabler去除水印在Windows11中删除评估副本水印的最简单方法是使用通用水印禁用程序,这是一个第三方免费软件

原标题:GraphAlign:EnhancingAccurateFeatureAlignmentbyGraphmatchingforMulti-Modal3DObjectDetection需要重写的内容是:论文链接:https://arxiv.org/pdf/2310.08261.pdf作者单位:北京交通大学河北科技大学清华大学论文思路:LiDAR和相机是自动驾驶中3D目标检测的互补传感器。然而,研究点云和图像之间的非自然交互具有挑战,关键在于如何进行异构模态的特征对齐。目前,许多方法仅通过投影

JSP注释的写法JSP注释有两种类型:单行注释和多行注释。单行注释单行注释以结束。注释的内容不会被解析,因此不会出现在输出中。例如:多行注释多行注释以/*开始,以*/结束。注释的内容不会被解析,因此不会出现在输出中。例如:/*这是一条多行注释*/JSP注释的应用场景

要求除了运行macOSMonterey12.3或更新版本以及iPadOS15.4或更新版本之外,您还需要更新的Mac(任何2016或更新的MacBookPro,或2018或更新的MacBookAir、Mini或iMac,或MacPro),以及更新的iPad(任何iPadPro、iPadAir第3代或更新版本、iPad第6代或更新版本、iPadMini第5代或更新版本)。任何想要使用UniversalControl的设备都需要登录到启用了iCloud的同一个AppleID帐户。立即通过Beta在M

微软Teams 终于收到了一个可以直接与最新 Mac PC 中基于 ARM 的芯片组交互的版本。针对 Apple Silicon 优化的 Teams Beta 版可直接从Microsoft获得.大约一年半前,Apple 发布了带有自己专有芯片组的 Mac PC。由苹果工程师设计的 M1 SoC 获得了很多好评。虽然上一代 Apple PC 采用英特尔处理器,但这些基于 ARM


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

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download
The most popular open source editor

Dreamweaver Mac version
Visual web development tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.
