vue-modal-provider
TypeScript icon, indicating that this package has built-in type declarations

0.4.1 • Public • Published

vue-modal-provider

nice-modal-react vue implementation. Simple to use and manage modal.

Document

HereThe online document.

Installation

$ npm install vue-modal-provider

Examples

Embed your application with ModalProvider

<!--App.vue -->
<script setup lang="ts">
import { RouterView } from "vue-router";
import { ModalProvider } from "vue-modal-provider";
</script>

<template>
  <ModalProvider>
    <RouterView />
  </ModalProvider>
</template>

Create modal component

<!-- Modal.vue -->
<template>
  <el-dialog v-model="visible">
    {{ args }}
    <el-button @click="hide(), resolve(1111), remove()">close</el-button>
  </el-dialog>
</template>

<script lang="ts" setup>
import { useModalRef } from "vue-modal-provider";
const {
  // show variables
  visible,
  // close modal
  hide,
  args,
  // remove modal lose animation
  remove,
  resolve,
  reject,
} = useModalRef();
</script>

Use in the view

<script lang="ts" setup>
import { useModal } from "vue-modal-provider";
import TestModal from "./Modal.vue";
const { show } = useModal(TestModal);

function showModal() {
  show("test msg").then((c) => {
    console.log(c);
  });
}
</script>

<template>
  <el-button @click="showModal">open modal</el-button>
</template>

Package Sidebar

Install

npm i vue-modal-provider

Weekly Downloads

59

Version

0.4.1

License

MIT

Unpacked Size

108 kB

Total Files

35

Last publish

Collaborators

  • shijinghui