在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()
})
})
在组件中使用
// 全局引入elementUI
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
Vue.use(ElementUI);
// 按需引入然后注册在vue原型上
import { Message} from 'element-ui';
Vue.prototype.$message = Message;
// 组件中调用
this.$message.success("退出成功");
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。