Message
# Message
Commonly used for feedback prompts after active operations. The difference from Notification is that the latter is more often used for passive system-level notifications.
# Basic Usage
Appears from the top and automatically disappears after 3 seconds.
# Different States
Used to display feedback for "success, warning, info, error" type operations.
# Closable
Can add a close button.
# Center Text
Use the center property to center text horizontally.
# Using HTML Fragments
The message property supports HTML fragments.
:::warning
Although the message property supports HTML fragments, dynamically rendering arbitrary HTML on websites is very dangerous as it can lead to XSS attacks (opens new window). Therefore, when dangerouslyUseHTMLString is enabled, ensure the message content is trusted and never assign user-submitted content to the message property.
:::
# Global Method
FxUI adds a global method $message to Vue.prototype. Therefore, in vue instances, Message can be invoked as shown on this page.
# Importing Separately
Import Message separately:
import { Message } from 'fx-ui';
In this case, the invocation method is Message(options). We have also defined methods for each type, such as Message.success(options). Additionally, you can call Message.closeAll() to manually close all instances.
# Options
| Parameter | Description | Type | Options | Default | PC/Mobile Support |
|---|---|---|---|---|---|
| message | Message text | string / VNode | — | — | PC/Mobile doesn't support VNode |
| type | Theme | string | success/warning/info/error | info | PC/Mobile only supports text/loading/success |
| iconClass | Custom icon class name, overrides type | string | — | — | PC/Mobile |
| dangerouslyUseHTMLString | Whether to treat message as HTML fragment | boolean | — | false | PC only |
| customClass | Custom class name | string | — | — | PC/Mobile |
| duration | Display duration in milliseconds. 0 means no auto-close | number | — | 3000 | PC/Mobile |
| showClose | Whether to show close button | boolean | — | false | PC only |
| center | Whether to center text | boolean | — | false | PC/Mobile |
| position | Text position | String | top/middle/bottom | middle | Mobile only |
| isMiddler | Whether to vertically center the message box | boolean | — | - | PC only |
| onClose | Callback when closed, parameter is the closed message instance | function | — | — | PC only |
| offset | Offset from the top of the window | number | — | 20 | PC only |
# Methods
Calling Message or this.$message returns the current Message instance. To manually close the instance, call its close method.
| Method | Description |
|---|---|
| close | Close current Message |