0.0.1 • Published 1 year ago

next-message v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Next-Message

travis-ci Coverage Status license release

A lightweight feedback message appearing at the top of the screen, fading automatically. Has many different options for different situations.

Edit new

Features

  1. No dependence,lightweight,200 lines of source code,Smaller after compression。
  2. UI Beautiful,Reference iview UI styles。

Install

  1. use unpkg cdn link
<script src="https://unpkg.com/next-message/index.js"></script>
<link rel="stylesheet" href="https://unpkg.com/next-message/index.css">

2.use npm or yarn install

$ npm install next-message
$ yarn add next-message

Use

use script,get global variable $message

use npm install,need import The module

import $message from 'next-message';
import 'next-message/index.css';

use in page

<!-- global configuration -->
$message.config({ top:85, duration: 4})

<!-- types -->
$message.info('this is a info message')
$message.success('this is a success message')
$message.warning('this is a info warning message')
$message.error('this is a info error message')
$message.loading('loading...')

<!-- onClose -->
$message.info('this is message can close', {
    onClose:() => console.log('close'),
    closable: true,
    duration: 6
})

<!-- destroy -->
$message.destroy()

API

Message instance

This component can be used with the following static methods:

  • $message.info(config)
  • $message.success(config)
  • $message.warning(config)
  • $message.error(config)
  • $message.loading(config)

Parameter config can be string or object. When string, the content will be directly displayed, when object, the detail usage is explained below:

PropertyDescriptionTypeDefault
durationTime before prompt dismisses, in seconds. Use 0 to not dismissNumber2
onCloseFunction to be called after the prompt is closedFunction-
closableWhether to show a close button.Booleanfalse
dangerUseHtmlwhether message is treated as HTML stringBooleanfalse

Methods for global configuration and disposal are also provided:

  • $message.config(options)
  • $message.destroy()
$Message.config({
    top: 50,
    duration: 3
});
PropertyDescriptionTypeDefault
topPrompt's distance from top, in pixels.Number24
durationDefault time before prompt dismisses, in seconds.Number1.5
singletonSingleton PatternBooleanfalse

License

Licensed under the MIT License.