1. UseUsing element's message component in Vue Use in Vue file this.$message({ message: "prompt message", type: "success" }) Use in js file import ElementUI from 'element-ui'; ElementUI.Message({ message: 'prompt message', type: 'warning' }); 2. Solve the problem of repeated display of message pop-up windows// message.js /** * @Description: Override message mounting to implement private properties of Class* @param { String } options => message content* @param { Boolean } single => whether to display only one*/ import { Message } from 'element-ui'; const showMessage = Symbol('showMessage'); class DonMessage { success (options, single = false) { this[showMessage]('success', options, single); } warning (options, single = false) { this[showMessage]('warning', options, single); } info (options, single = false) { this[showMessage]('info', options, single); } error (options, single = true) { this[showMessage]('error', options, single); } [showMessage] (type, options, single) { if (single) { // Determine if Message already exists if (document.getElementsByClassName('el-message--error').length === 0) { Message[type](options); } } else { Message[type](options); } } } // Default export of private Message component export default new DonMessage(); Introduce where necessary import DonMessage from '@/message' Use directly in js file DonMessage.warning('Please log in') Mounted on the vue prototype // main.js Vue.prototype.$message = DonMessage // Call this.$message.warning("Please log in") in the vue file This is the end of this article about how to solve the problem of repeated pop-up of Element’s Message pop-up. For more information about repeated pop-up of Element’s Message pop-up, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: MySQL encoding utf8 and utf8mb4 utf8mb4_unicode_ci and utf8mb4_general_ci
>>: How to install and connect Navicat in MySQL 8.0.20 and what to pay attention to
The props of the component (props is an object) F...
1. Unzip to the location where you want to instal...
Last time we talked about some SQL query optimiza...
Table of contents Method 1: set: It is not a data...
Table of contents MySQL query tree structure 1. A...
About Nginx, a high-performance, lightweight web ...
When Docker starts a container, it specifies the ...
Table of contents 1. What is Set 2. Set Construct...
Table of contents 2. Stack analysis using pt-pmap...
Use of built-in functions in the database This ar...
download: Step 1: Open the website (enter the off...
Table of contents 1. Preparation 2. Define the gl...
In this article, the blogger will take you to lea...
Real-time replication is the most important way t...
Failure Scenario When calling JDBC to insert emoj...