npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mu-alert

v1.0.2

Published

Web前端开发 常用弹窗、抽屉、确认框、弹出层、加载框、模态框、消息提示

Downloads

11

Readme

MU-ALERT


MIT License

Web 前端开发 常用弹窗、抽屉、确认框、加载框、弹出层、模态框、消息提示等工具集!

下载安装:

# 使用npm命令下载安装
$ npm i mu-alert

# 使用yarn命令下载安装
yarn add mu-alert

使用方法:

  • 通过 JS Module(模块)方式导入使用

    <!-- ES6模块导入使用 -->
    <script type="module">
      /**
       * 1、全部引入使用
       **/
      import * as mu from "mu-alert";
    
      // 在浏览器控制台中打印mu-alert的所有方法
      console.log(mu);
    
      // 显示加载动画
      mu.loading();
    
      // 关闭加载动画
      mu.loading.close();
    
      /**
       * 2、按需引入使用
       **/
      import { loading, message, notice, drawer, dialog } from "mu-alert";
    
      // 显示加载动画
      loading();
    
      // 关闭加载动画
      loading.close();
    </script>
  • 通过 script 标签以 CDN 的形式引入使用

    <!-- 将mu-alert.js下载后,在html文件中引入本地脚本 -->
    <script src="./js/mu-alert"></script>
    <script>
      // 在浏览器控制台中打印mu-alert的所有方法
      console.log(mu);
    
      // 显示加载动画
      mu.loading;
    
      // 关闭加载动画
      mu.loading.close();
    </script>

重写方法:

  • alert() 弹框

    重写 window 对象下的 alert 方法。

    /**
     * @param {String} message // 要弹出的文本
     * @returns Undefined
     */
    
    alert("Hello World");
  • confirm() 确认框

    重写 window 对象下的 confirm 方法。

    /**
     * @param {String} message // 要提示的文本
     * @param {Function} enterFn // 确定回调方法
     * @param {Function} cancelFn // 取消回调方法
     * @returns Undefined
     */
    
    confirm(
      "Hello World",
      () => {
        // 点击了确定按扭
      },
      () => {
        // 点击了取消按扭
      }
    );

支持情况:

  • loading() 请求加载

    常用于数据请求、数据加载等待时 显示的反馈动效。

    // 显示加载动画
    mu.loading();
    
    // 关闭加载动画
    mu.loading.close();
  • message() 消息提示

    常用于主动操作后的反馈提示。在顶部居中显示,并自动消失。有多种不同的提示状态可选择。

    /**
     * @param {String | Object}  // 提示内容 | 样式类型
     * @returns Undefined
     */
    
    // 调用方式1
    mu.message("我是message消息提示,我在3秒后会自动关闭!");
    
    // 调用方式2 success(): 成功提示,error():错误提示,warning():警告提示
    mu.message.success("我是message消息提示,我会在3秒后自动关闭!");
    
    // 调用方式3
    mu.message({
      type: "success", // "success": 成功提示,"error":错误提示,"warning":警告提示
      message: "我是message消息提示,我会在3秒后自动关闭!",
      duration: 3000   // 显示时间(默认3秒), 单位(毫秒)
    });

后续更新。。。!