Message 消息提示 :
引入方式:
Vue.prototype.$message=Message;
this.$message(options)
import {Message} from 'element-ui'
Message(options)
常用参数:
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|
message | 消息文字 | string / VNode | — | — |
type | 主题 | string | success/warning/info/error | info |
iconClass | 自定义图标的类名,会覆盖 type | string | — | — |
dangerouslyUseHTMLString | 是否将 message 属性作为 HTML 片段处理 | boolean | — | false |
customClass | 自定义类名 | string | — | — |
duration | 显示时间, 毫秒。设为 0 则不会自动关闭 | number | — | 3000 |
showClose | 是否显示关闭按钮 | boolean | — | false |
center | 文字是否居中 | boolean | — | false |
onClose | 关闭时的回调函数, 参数为被关闭的 message 实例 | function | — | — |
offset | Message 距离窗口顶部的偏移量 | number | — | 20 |
方法:
方法名 | 说明 | 调用 |
---|
close | 关闭当前的 Message | |
方法使用注意:像定时器一样,Message有返回值;调用close()关闭 也需要像定时器一样,接收,清掉。
使用分析:
this.$message({
message:'消息内容',
type:'success/error/warnings',
showClose: true,
center:true,
duration:3000,
dangerouslyUseHTMLString: true,
message: '<strong>这是 <i>HTML</i> 片段</strong>'
customClass:'className'
iconClass:el-icon-setting,
onClose:()=>{
},
offset:20
})