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组件自动触发](https://www.haoht123.com/wp-content/uploads/2019/12/elementui.jpg)
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组件自动触发](https://www.haoht123.com/wp-content/uploads/2019/12/message_info.png)
Why is this problem? Then I carefully read the official documents and found that the introduction on demand needs to be as follows:
- import Vue from 'vue';
- import { Message } from 'element-ui';
- Vue.prototype.$message = Message;
I quote it as follows:
- import Vue from 'vue';
- import { Message } from 'element-ui';
- 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.