Skip to content

Message

Used to show feedback after an activity.

Methods

  • Global method:Tu View Plus has added a global method $message for app.config.globalProperties. So in a vue instance you can call Message like what we did in this page.

  • Local import:in this case you should call TuMessage(options). We have also registered methods for different types, e.g. TuMessage.success(options). You can call TuMessage.closeAll() to manually close all the instances.

Basic usage

Displays at the top, and disappears after 3 seconds.

Types

Used to show the feedback of Success, Warning, Message and Error activities.

Closable

A default Message cannot be closed manually. If you need a closable message, you can set showClose field. Message has a controllable duration. Default duration is 3000 ms, and it won not disappear when set to 0.

Centered text

Use the center attribute to center the text.

Custom icon

Use the icon attribute to set header icon.

Use HTML string

Set dangerouslyUseHTMLString to true and message will be treated as an HTML string.

Grouping

Set grouping to true and the same content of message will be merged.

Message API

Message Attributes

NameDescriptionTypeDefault
messageMessage textString VNode Function-
typeMessage typeString''
iconCustom icon componentString Component-
dangerouslyUseHTMLStringWhether message is treated as HTML stringBooleanfalse
customClassCustom class name for MessageString''
durationDisplay duration, millisecond. If set to 0, it will not turn off automaticallyNumber-
showCloseWhether to show a close buttonBooleanfalse
centerWhether to center the textBooleanfalse
onCloseCallback function when closed with the message instance as the parameterFunction-
offsetSet the distance to the top of viewportNumber16
appendToSet the root element for the message, default to document.bodyString HTMLElement-
groupingMerge messages with the same content, type of VNode message is not supportedBooleanfalse
repeatNumThe number of repetitions, similar to badge, is used as the initial number when used with groupingNumber1

Message Events

Message and this.$message returns the current Message instance. To manually close the instance, you can call close on it.

NameDescriptionType
closeClose the MessageFunction