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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@beisen-phoenix/mobile-toast

v2.0.2

Published

移动端基础组件-toast

Readme

吐司弹框

用法

npm install --save @beisen-phoenix/mobile-toast

import Toast from '@beisen-phoenix/mobile-toast';
Toast.success('您的钱包已入账 1,000,000,000 元');
Toast.success({
	content: '您的钱包已入账 1,000,000,000 元',
	customZIndex: 1000,
	mask: true,
	duration: 2,
	onClose() {
		console.log('');
	}
});

接口

Toast 显示一个全屏居中的信息提示框,它有一些方法来显示不同风格的图标表示不同的情况。多次调用会产生多个独立的 Toast,后面的在 Z 方向上覆盖前面的。

方法如下:

  • success: 显示成功图标
  • fail: 显示失败图标
  • info: 显示提示信息图标
  • offline: 显示断网图标
  • loading: 显示加载中图标

它们都有如下一些参数:

| name | description | type | default | required | | ------------ | ---------------------------------------------------------------------------------------- | ------------------------- | ------------------------------- | -------- | | content | 显示的内容,可以是字符串,也可以是 ReactNode | string | React.ReactNode | | 是 | | duration | 持续显示的时间,单位不是毫秒) | number | 1.5 (loading时为 604800) | 否 | | onClose | 关闭时的回调。手动调用ToastInstance.close()时不会触发此回调 | () => void | undefined | 否 | | mask | 是否启用透明的背景,当启用时会导致类似模态对话框的行为,会阻止页面上的其它操作。默认启用 | boolean | true | 否 | | customZIndex | 自定义 z-index | number | N/A | 否 |

changelog 2019/10/24 将 success、fail、info、offline、loading 等方法接收的参数调整为 string 或者 object

注意durationloading时默认值是 604800,因为一般在调用 loading 时都需要手动调用ToastInstance.close()关闭。

这些方法都会返回一个ToastInstance类型的对象,可以调用其close方法来关闭这个 Toast:

interface ToastInstance {
	close: () => void;
}

show

另外还有一个show方法,可以用来实现更高级的功能,本质上上述的 success、fail 等最终都是调用的它。它的参数为ToastOptions类型:

interface ToastOptions {
	icon?: React.ReactNode; // 如果不传则不会显示图标
	content?: string | React.ReactNode; // 如果不传则不会显示该区域
	duration?: number; // 默认值1.5秒
	mask?: boolean;
	onClose?: () => void;
}