Giter Site home page Giter Site logo

snwjas / message.js Goto Github PK

View Code? Open in Web Editor NEW
28.0 1.0 10.0 103 KB

一款优雅的原生JS页面消息提示插件,兼容性良好,无任何依赖。 An elegant native JS page message prompt plug-in, good compatibility, no dependency.

Home Page: http://qmsg.refrain.xyz/

JavaScript 81.81% SCSS 18.19%
message javascript prompt

message.js's Introduction

Message.js

**插件描述:**一款优雅的原生JS页面消息提示插件,兼容性良好,无任何依赖。

**声明:**此插件非笔者原创,笔者只做了部分内容的修改,以符合个人需求。以下为原插件来源信息:

message.js

使用:

html引入:

<link rel="stylesheet" href="./message.min.css">
<!-- your html -->
<script src="./message.min.js"></script>
<script>
    var configs = {};
    // configs 为配置参数,可省略
    Qmsg.info("这是提示消息",configs);
</script>

全局配置

在引入message.js之前可以通过全局变量 QMSG_GLOBALS.DEFAULTS 来进行配置

window.QMSG_GLOBALS = {
    DEFAULTS: {
        showClose:true,
        timeout: 5000
    }
}

或者通过Qmsg.config({})来动态修改全局配置:

Qmsg.config({
    showClose:true,
    timeout: 5000
})

所有支持的配置信息如下:

**参数名 ** **类型 ** **描述 ** **默认 **
showClose Boolean 是否显示关闭图标 false
autoClose Boolean 是否自动关闭 true
timeout Number 自动关闭时,消息的持续显示时间,单位 ms 2000
content String 提示的消息内容 ''
onClose Function 关闭时的回调函数 null
html Boolean 是否将内容作为 html 渲染 false
maxNums Number 页面中最多显示消息(autoClose: true)的数量 5

Qmsg支持的方法

Qmsg.info()
Qmsg.warning()
Qmsg.error()
Qmsg.success()
Qmsg.loading()

以上方法均可传递 1-2 个参数,如下:

Qmsg.loading("我是加载条");
Qmsg.info("给你个眼神,你懂得",{
    showClose:true,
    onClose:function(){
        console.log('我懂了')
    }
})
Qmsg.error({
    content:"1+1=3",
    timeout:5000
})

注意:Qmsg.loading()默认设置autoClose = false,一般来说需要手动关闭:

var loadingMsg = Qmsg.loading('我是加载条');
// do something
loadingMsg.close();

如需要自动关闭则需要如下调用:

Qmsg.loading("我是加载条",{
    autoClose:true
})
// 或者
Qmsg.loading({
    autoClose:true,
    content:"我是加载条"
})

Qmsg.closeAll()

关闭所有消息,包括autoClose = false的消息

var aMsg = Qmsg.info("这是个info消息")

close()

关闭当前消息,会触发onClose回调函数。

aMsg.close()

destroy()

销毁消息,不会触发onClose回调函数。

aMsg.destroy()

message.js's People

Contributors

snwjas avatar

Stargazers

LF_Mcxixif_ avatar 崽崽 avatar 刘君 avatar cxwovo avatar 灿烈 avatar Wanpan avatar  avatar zhenghy avatar 姜姜姜 avatar Yang avatar  avatar 会编程的猫 avatar sunsky avatar 油老师 avatar 小赵同学 avatar Song Baoming avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar waylon avatar Veen Zhao avatar Rils_s avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.