UNPKG

vue3-watermark-plugin

Version:

A powerful Vue 3 watermark plugin with component and directive support

33 lines (27 loc) 863 B
/** * 全局指令注册 */ import watermarkDirective from './watermark.js'; // 支持 app.use() 方式注册的插件对象 const directivesPlugin = { install(app, options = {}) { // 注册水印指令 app.directive('watermark', watermarkDirective); // 可以根据 options 进行配置 if (options.globalWatermark) { // 全局水印配置 app.config.globalProperties.$watermarkConfig = options.globalWatermark; } // 可以添加更多指令 // app.directive('other-directive', otherDirective); }, }; // 传统函数方式注册 function setupDirectives(app) { // 注册水印指令 app.directive('watermark', watermarkDirective); } // 默认导出插件对象,支持 app.use() export default directivesPlugin; // 也导出函数形式,保持向后兼容 export { setupDirectives, watermarkDirective };