elementUI中message的用法

在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("退出成功");

おすすめ

転載: blog.csdn.net/weixin_43848576/article/details/120302166