Solve the automatic triggering of Message component in element ui

December 29, 2019 13:40:37 Comment Reading (2240)
This article was last updated on December 29, 2019, and has not been updated for more than a year. If the article content or picture resources are invalid, please leave a message for feedback, and we will deal with it in a timely manner, thank you!

解决element-ui中Message组件自动触发

When using elementui in the vue project, I encountered a problem. My Element version is 2.13.0. When the Message component is introduced on demand, a default message will always pop up automatically when the page is refreshed. I was puzzled. A search online found that many people have encountered this problem.

解决element-ui中Message组件自动触发

 

Why is this problem? Then I carefully read the official documents and found that the introduction on demand needs to be as follows:

  1. import  Vue from 'vue';
  2. import  { Message } from 'element-ui';
  3. Vue.prototype.$message = Message;

I quote it as follows:

  1. import  Vue from 'vue';
  2. import  { Message } from 'element-ui';
  3. Vue.use(Message)

In this way, Message will always be triggered automatically when the page is refreshed. The problem will be solved according to the official document.

 

 

 weinxin
WeChat applet
Internet development, lifelong learners, welcome your attention!
 Willing

Comment

 unhappy  rainbow  look on  Diu Xiang  Good  funny  Flower core  Cry out  surprised  blink the eyes  Cool  Sad  Are you handsome?  gift  rose  anger  get angry  spray  Sleep?  Too happy  Little 999  ah
 sunlight  Spit out one's tongue  Grievance  smiling eyes  Star Moon  heart-broken  Eh  Insidious  doubt  that 's great  Snicker  Squint  shock  slightly  Yawn  Helpless to cry  Pick one's nose  Hum  expect  I don't care about you  love  candle