iview-mpvue
  • 首页
  • 布局
    • Layout 栅格布局
    • Grid 宫格
    • Panel 面板
    • List 列表
    • Card 卡片
  • 基础组件
    • Button 按钮
    • Color 色彩
    • Icon 图标
  • 导航
    • TabBar 标签栏
    • Tabs 标签页
    • Drawer 抽屉
    • Page 分页
    • Steps 步骤条
    • NoticeBar 通告栏
    • Index 索引选择器
    • Sticky 吸顶容器
  • 操作反馈
    • ActionSheet 动作面板
    • Toast 轻提示
    • Modal 对话框
    • Message 全局提醒
    • Spin 加载中
    • Swipeout 滑动菜单
  • 视图
    • Badge 徽章
    • Alert 警告提示
    • Tag 标签
    • Progress 进度条
    • Avatar 头像
    • CountDown 倒计时
    • Divider 分隔符
    • Collapse 折叠面板
    • LoadMore 页底提示
  • 表单
    • Input 输入框
    • Radio 单选
    • Checkbox 复选
    • Switch 开关
    • Rate 评分
    • InputNumber 数字输入框
Powered by GitBook
On this page
  • 概述
  • 使用指南
  • 示例
  • API

Was this helpful?

  1. 操作反馈

Message 全局提醒

概述

轻量级的信息反馈组件,在顶部居中显示,并自动消失。有多种不同的提示状态可选择。

使用指南

在.vue中引入组件

<script>
    import iMessage from 'iview-mpvue/dist/components/message/message'
    export default {
        components: {
            'i-message': iMessage
        }  
    }
</script>

在main.js中引入样式文件

import 'iview-mpvue/dist/components/message/style/css'

示例

<div style="margin-top: 100px">
    <i-button type="ghost" @click="handleDefault">默认提醒</i-button>
    <i-button type="ghost" @click="handleSuccess">成功提醒</i-button>
    <i-button type="ghost" @click="handleWarning">警告提醒</i-button>
    <i-button type="ghost" @click="handleError">错误提醒</i-button>
    <i-button type="ghost" @click="handleDuration">自定义持续时间</i-button>
</div>
<i-message ref="message" />
<script>
import { $Message } from 'iview-mpvue/dist/components/base/index'
export default {
  ...
  methods: {
      handleDefault() {
          $Message(this, {
              content: '这是一条普通提醒'
          })
      },
      handleSuccess () {
          $Message(this, {
              content: '这是一条成功提醒',
              type: 'success'
          })
      },
      handleWarning () {
          $Message(this, {
              content: '这是一条警告提醒',
            type: 'warning'
          })
      },
      handleError () {
          $Message(this, {
              content: '这是一条错误提醒',
              type: 'error'
          })
      },
      handleDuration () {
          $Message(this, {
              content: '我将在 5 秒后消失',
              duration: 5
          })
      }
  }
}
</script>

API

$Message properties

属性

说明

类型

默认值

context

Vue实例上下文

Object

content

内容

String

-

type

内置的类型,可选值为 default、success、warning、error

String

default

duration

持续时间,单位秒

Number

2

ref

组件标识

String

message

PreviousModal 对话框NextSpin 加载中

Last updated 5 years ago

Was this helpful?