Notice-Message消息提示
常用于主动操作后的反馈提示。与 Notification 的区别是后者更多用于系统级通知的被动提醒。
当需要自定义更多属性时,Message 也可以接收一个对象为参数。比如,设置type
字段可以定义不同的状态,默认为info
。此时正文内容以message
的值传入。同时,我们也为 Message 的各种 type 注册了方法,可以在不传入type
字段的情况下像open4
那样直接调用。
<el-button :plain="true" @click="open2">成功</el-button>
<el-button :plain="true" @click="open3">警告</el-button>
<el-button :plain="true" @click="open">消息</el-button>
<el-button :plain="true" @click="open4">错误</el-button>
<script>
export default {
methods: {
open() {
this.$message('这是一条消息提示');
},
open2() {
this.$message({
message: '恭喜你,这是一条成功消息',
type: 'success'
});
},
open3() {
this.$message({
message: '警告哦,这是一条警告消息',
type: 'warning'
});
},
open4() {
this.$message.error('错了哦,这是一条错误消息');
}
}
}
</script>
Options
参数 | 说明 | 类型 | 可选值 | 默认值 |
---|---|---|---|---|
message | 消息文字 | string / VNode | — | — |
type | 主题 | string | success/warning/info/error | info |
还没有评论,来说两句吧...