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

antd-message-vue

v1.0.2

Published

A Vue component for displaying messages with Ant Design style.

Downloads

2

Readme

antd-message-vue

antd-message-vue 是一个 Vue 插件,模仿了 Ant Design 的 message 组件,提供全局消息通知功能,支持成功、警告、错误、加载和信息消息类型。它允许你在应用中方便地显示各种类型的消息, 并可以自定义消息的显示时间和回调函数。

安装

使用 npm 安装插件:

npm install antd-message-vue

或者使用 yarn:

yarn add antd-message-vue

使用

在 Vue 应用中注册插件

在你的 Vue 应用的入口文件(如 main.tsmain.js)中,注册插件并导入 CSS:

import { createApp } from "vue";
import App from "./App.vue";
import { install as messagePlugin } from "antd-message-vue";
import "antd-message-vue/style.css";

const app = createApp(App);
app.use(messagePlugin);
app.mount("#app");

直接使用 Message 类

你也可以直接导入 Message 类并调用其方法:

import { Message } from "antd-message-vue";
import "antd-message-vue/style.css";

Message.success("This is a success message!");

Message.error("This is an error message!", {
    timeout: 5000,
    callBack: () => {
        console.log("Error message closed");
    },
});

设置全局主题

你可以设置全局的主题颜色和字体颜色:

import { Message } from "antd-message-vue";
import "antd-message-vue/style.css";

// 设置全局主题颜色和字体颜色
Message.setGlobalTheme({ themeColor: "#1890ff", fontColor: "#ffffff" });

Message.success("This is a success message with global theme!");

API

Message

Message 类提供了以下静态方法:

  • setGlobalTheme(options: ThemeOptions): void

    设置全局的主题颜色和字体颜色。 options 是一个包含 themeColorfontColor 的对象。

  • success(content: string, options?: MessageOptions): () => void

    显示成功消息。 options 是可选参数,用于设置消息显示的时间、回调函数、主题颜色和字体颜色。

  • warn(content: string, options?: MessageOptions): () => void

    显示警告消息。 options 参数与 success 方法相同。

  • error(content: string, options?: MessageOptions): () => void

    显示错误消息。 options 参数与 success 方法相同。

  • loading(content: string, options?: MessageOptions): () => void

    显示加载消息。 options 参数与 success 方法相同。

  • info(content: string, options?: MessageOptions): () => void

    显示信息消息。 options 参数与 success 方法相同。

install

install 方法用于将插件安装到 Vue 应用中:

  • install(app: App): void

    将插件安装到 Vue 应用中。

interface

interface ThemeOptions {
    themeColor?: string;
    fontColor?: string;
}

interface MessageOptions extends ThemeOptions {
    timeout?: number;
    callBack?: () => void;
}

贡献

欢迎提交 issue 和 pull request。如果你有任何问题或建议,请在 GitHub 上报告。

许可证

该项目使用 MIT 许可证。