在js文件中直接使用message
import {
MessageBox, Message } from 'element-ui'
Message({
message: res.message || 'Error',
type: 'error',
duration: 5 * 1000
})
MessageBox.confirm('You have been logged out, or log in again', 'Confirm logout', {
confirmButtonText: 'Re-Login',
cancelButtonText: 'Cancel',
type: 'warning'
}).then(() => {
store.dispatch('user/resetToken').then(() => {
location.reload()
})
})
在组件中使用
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
Vue.use(ElementUI);
import {
Message} from 'element-ui';
Vue.prototype.$message = Message;
this.$message.success("退出成功");