天天看點

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

繼續閱讀