• Stars
    star
    157
  • Rank 238,399 (Top 5 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A message plugin for vue.

vue-m-message

A message plugin base on Vue.

v4.x version only supports Vue 3; If you use Vue 2, use v3.x instead.

Preview

中文 | Live Demo

npm install vue-m-message

# Vue 2
# npm install vue-m-message@3
import { createApp, h } from 'vue'
import Message from 'vue-m-message'
import 'vue-m-message/dist/style.css'
import App from './App.vue'

const app = createApp(App)

app.use(Message)
// or
app.use(Message, options: { name?: string, defaultOptions?: MessageTypeOptions })

// Message.info('Wellcome here !', { duration: -1, ctx: instance?.appContext })
// Message.info(h('m-demo', 'Wellcome here !'), { duration: -1 })
Message.info(() => h('div', [
  'Here is playground for ',
  h('a', { href: 'https://github.com/mengdu/m-message' },'Vue Message'),
  ' plugin.'
]), {
  title: 'Wellcome here !',
  duration: -1,
  iconURL: 'https://avatars.githubusercontent.com/u/11366654?s=40&v=4'
})
// Message.info(<m-demo>Wellcome here !</m-demo>, { duration: -1 })
// Message.info(() => <m-demo>Wellcome here !</m-demo>, { duration: -1 })

app.mount('#app')

Message API

  • Message(options: MessageOptions): MessageIntance General prompt information
  • Message.info(message: string | VNode | (() => VNode), options?: MessageTypeOptions): MessageIntance Info prompt information
  • Message.success(message: string | VNode | (() => VNode), options?: MessageTypeOptions): MessageIntance Success prompt information
  • Message.error(message: string | VNode | (() => VNode), options?: MessageTypeOptions): MessageIntance Error prompt information
  • Message.warning(message: string | VNode | (() => VNode), options?: MessageTypeOptions): MessageIntance Warning prompt information
  • Message.loading(message: string | VNode | (() => VNode), options?: MessageTypeOptions): MessageIntance Loading prompt information
  • Message.closeAll(): void Clear all prompts
  • Message.setDefault(options: MessageTypeOptions): void Set default values
type MessageTypeOptions = Omit<MessageOptions, 'type' | 'message'>

interface MessageIntance {
  id: string
  close: () => void
}

MessageOptions

Attribute Description Type Optional value Default
type Message type icon string '', 'info', 'success', 'error', 'warning', 'loading' 'info'
iconURL Replace type icon with picture string
title Message title string ''
message Message content string ''
position Message display position string 'top-left', 'top-center', 'top-right', 'center', 'bottom-left', 'bottom-center', 'bottom-right'
duration Message display duration, in MS; When ` - 1 ', it needs to be closed manually number 3000
width Message block width, auto width by default string ''
className class name string
wrapperClassName class name for wrapper string
zIndex z-index number 1010
supportHTML Whether the message content supports HTML (only valid when the message is a string) boolean true/false false
isCollapsed Collapse content boolean true/false false
collapsable Collapsable boolean true/false false
closable Whether it can be closed boolean true/false false
hasMask Does it contain a mask boolean true/false false
stopTimerOnHover Whether to recalculate the display duration when the mouse moves over boolean true/false true
onClose Close callback () => void
onCollapsed Fold switch callback (collapsed: boolean) => void

License

Licensed as MIT.

More Repositories

1

vue-element-admin-tpl

Admin platform template base on vue + element-ui
CSS
381
star
2

vue-electron-chrome

基于electron开发的应用浏览器
JavaScript
148
star
3

validator.js

A simple JavaScript data validation library
TypeScript
52
star
4

poster

浏览器端video视频截图,视频封面获取
JavaScript
44
star
5

vue-component-devtool

Vue 组件开发模板
JavaScript
33
star
6

m-dialog

A dialog component for vue.
TypeScript
27
star
7

page

简单的PHP分页类
PHP
19
star
8

log.js

node.js 控制台日志打印工具
JavaScript
16
star
9

m-button

A beautiful button component for vue.
JavaScript
15
star
10

react-concise-router

A concise router base on react-router.
JavaScript
15
star
11

m-monaco-editor

A monaco-editor component for vue.(基于cdn版本)
JavaScript
11
star
12

vue-dotmd-loader

A webpack loader for markdown file transform to vue file.
JavaScript
10
star
13

m-quill-editor

A quill editor component for vue.
JavaScript
8
star
14

vite-react-ssr

Server Side Rendering project template base on Vite + React
JavaScript
7
star
15

m-crop

Vue 简单的图片区域裁切组件。
JavaScript
7
star
16

m-table

A table component for vue.
JavaScript
5
star
17

m-ace-editor

An ace editor component for vue.
JavaScript
5
star
18

simple-translate

基于百度翻译API的翻译扩展
JavaScript
4
star
19

ant-admin-platform

An admin platform based on Ant design.
JavaScript
4
star
20

query-builder

A simple mysql query builder.
TypeScript
4
star
21

QRcode-tool

一款简洁的二维码生成工具,Chorme 浏览器扩展
JavaScript
4
star
22

vite-plugin-markdown-vue

Vite plugin for markdown to Vue.
JavaScript
4
star
23

marqueejs

marquee 前端跑马灯,滚动字幕
JavaScript
2
star
24

extension-manager

An Extension manager for chrome.
CSS
2
star
25

cnode-react-ssr

CNode社区 - React SSR
JavaScript
2
star
26

dev-cli

cli 命令行工具(持续集成)
JavaScript
2
star
27

node-bugjs

node-bugjs 是 node.js 的一个调试工具。
JavaScript
2
star
28

m-grid

A gird layout component for vue
JavaScript
2
star
29

grpc-etcd-resolver

Etcd resolver for grpc-node.
TypeScript
1
star
30

code13

code13条形码PHP生成类
PHP
1
star
31

goerror

Error contains call stack information.
Go
1
star
32

vscode-hosts-helper

A helper for editing hosts files.
TypeScript
1
star
33

requiresjs

一个node模块加载工具
JavaScript
1
star