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

vue2-modals

v1.0.1

Published

1. 引用

Readme

vue2-models 一个基于 vue2 的一个命令式调用 modal

使用

  1. 引用
import Modal from "vue2-modals";
Vue.use(Modal);
  1. 初始化
const modal = new Modal({
  modals: [
    {
      name: "modalName",
      component: () => import("./components/HelloWorld.vue"),
    },
  ],
});

new Vue({
  modal,
  render: (h) => h(App),
}).$mount("#app");
  1. 在 App.vue 使用 modalView 组件
<!-- modalView是全局组件,所以不需要引入,后面调用的modal会在这个modalView展示 -->
<template>
  <div id="app">
    <modal-view name="fade" />
  </div>
</template>
  1. 编写 modal 弹窗
<template>
  <div class="hello">
    {{ msg }}
    <button @click="onChange">促发emit</button>
    <button @click="closeModal">关闭弹窗</button>
  </div>
</template>

<script>
  export default {
    name: "HelloWorld",
    props: {
      msg: String,
    },
    methods: {
      closeModal() {
        this.$modal.close();
      },
      onChange() {
        this.$emit("change", "hello world");
      },
    },
  };
</script>
  1. 使用
// this.$modal是当前new Modal的实例已经自定注册
await this.$modal.open("modalName", {
  // 传递给组件的props
  props: {
    msg: this.msg,
  },
  // 监听$emit出来得事件
  on: {
    change: (val) => {
      this.$modal.close();
    },
  },
});
  1. API
  • open(modalName,{props,on}) 打开弹窗
  • close() 关闭弹窗
  • modal-view 组件接收 name 属性,传递给 Vue 的 Transition 组件 以来添加显示消失动画