
Research
/Security News
Contagious Interview Campaign Escalates With 67 Malicious npm Packages and New Malware Loader
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
vue-modal-core
Advanced tools
一个轻量级且灵活的 Vue 3 模态框组件库,为您的 Vue 应用提供更好的模态框管理方案。
npm install vue-modal-core
# 或
yarn add vue-modal-core
# 或
pnpm add vue-modal-core
1.创建实例
// dialog.ts
import { createModalContext } from 'vue-modal-core';
export { makeModal, ModalRenderer } = createModalContext({
allowMultiple: true
});
<!-- MyModal.vue -->
<script setup lang="ts">
import { onBeforeClose } from 'vue-modal-core';
defineProps<{
content: string;
}>()
defineModel<boolean>('visible')
// 在模态框组件中使用关闭前钩子
onBeforeClose(async () => {
await new Promise(resolve => setTimeout(resolve, 1000));// 等待 1 秒
// 返回 false 可以阻止模态框关闭
});
</script>
<template>
<div class="modal" :class="{ 'show': visible }">
<div class="modal-content">
{{ content }}
<button @click="$emit('update:visible', false)">关闭</button>
</div>
</div>
</template>
import { makeModal } from './dialog';
import MyModal from './MyModal.vue';
// 创建模态框上下文
// 创建模态框实例
const modal = makeModal(MyModal);
// 打开模态框
modal.open({
// 传入 props
content: 'Hello, World!'
});
setTimeout(() => {
modal.close();
}, 3000);
<!-- App.vue -->
<script setup lang="ts">
import { ModalRenderer } from './dialog';
</script>
<template>
<Teleport to="body">
<ModalRenderer />
</Teleport>
<!-- Page Content -->
</template>
创建模态框上下文,返回模态框管理器实例。
interface ModalOptions {
allowMultiple?: boolean; // 是否允许多个模态框同时存在
debug?: boolean; // 是否启用调试模式
}
const context = createModalContext(options?: ModalOptions);
创建模态框实例。
const modal = makeModal(YourModalComponent);
// 返回的实例包含以下方法:
interface ModalInstance {
open: (props: ComponentProps) => void; // 打开模态框
close: () => Promise<boolean>; // 关闭模态框
isVisible: () => boolean; // 获取模态框可见状态
}
添加模态框关闭前的钩子函数。
onBeforeClose(() => {
// 返回 false 可以阻止模态框关闭
return true;
});
FAQs
一个轻量级的 Vue 3 模态框管理库,提供灵活的模态框控制和生命周期管理
The npm package vue-modal-core receives a total of 0 weekly downloads. As such, vue-modal-core popularity was classified as not popular.
We found that vue-modal-core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.