An open API service indexing awesome lists of open source software.

https://github.com/gitguanqi/xqmsg

This is a js show message tip plugin.
https://github.com/gitguanqi/xqmsg

javascript msg

Last synced: 9 months ago
JSON representation

This is a js show message tip plugin.

Awesome Lists containing this project

README

          

# xqmsg

This is a js show message tip plugin.

[View Chinese documents](./zh.md)

## Install

**Browser**:

import cdn

```html

import xqmsg from '../lib/js/xqmsg-esm.min.js';

```

## Usage

+ html

```html

1. pop



success
error
warning
info


2.msg



top
middle
bottom


3.confirm



confirm


```

+ call

```js
// 1. pop
let popBtn = document.querySelectorAll('.popBtn');
for (let i = 0; i < popBtn.length; i++) {
const item = popBtn[i];
item.addEventListener('click', popSet, false);
}

function popSet (event) {
let e = event || window.event;
let params = e.target.dataset;
xqmsg.pop(params.text, params.type);
}

// 2.msg
let msgBtn = document.querySelectorAll('.msgBtn');
for (let i = 0; i < msgBtn.length; i++) {
const item = msgBtn[i];
item.addEventListener('click', msgSet, false);
}

function msgSet (event) {
let e = event || window.event;
let params = e.target.dataset;
xqmsg.msg(params.text, params.type);
}

// 3.confirm
let confirmBtn = document.querySelector('.confirmBtn');
confirmBtn.addEventListener('click', confirmSet, false);
async function confirmSet () {
let res = await xqmsg.confirm('You want to leave me?');
console.log(res);
// {type: 1, msg: 'confirm'}
// {type: 2, msg: 'cancel'}
}
```

## View xqmsg

Run this script to view the demonstration case: `npm run test:browser`.

+ [demo](https://xqgj.cc/xqmsg/test/browser.html)

## ask questions

[submit your question](https://github.com/gitguanqi/xqmsg/issues/new)

## Author

[@gitguanqi](https://github.com/gitguanqi)