vue3-window-events
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

Global window events component for vue 3

This component adds all given listeners to window component and removes them when component unmounts.

Intallation

For npm:

npm install vue3-window-events

For pnpm:

pnpm add vue3-window-events

For yarn:

yarn add vue3-window-events

Usage

Import the component and use like a regular component.

component.vue

<template>
   <WindowEvents @keyup.tab.prevent="yesItWorks()" @click="doSomething" />
</template>

<script setup>
   import { WindowEvents } from 'vue3-window-events';
</script>

component.tsx

import { WindowEvents } from 'vue3-window-events';
import { defineComponent } from 'vue';

const MyComponent = defineComponent({
   render() {
      return (
         <div>
            <WindowEvents
               onClick={(e) => {
                  e.clientX ? e.clientX : e.clientY;
               }}
               onPopState={(e) => {
                  doSomethingWith(e);
               }}
            />
         </div>
      );
   }
});

What about TypeScript?

This package has built-in typescript support for emits and props, you will have no trouble while using it.

Auto completion

To have types support in vue files I recommend you to use Volar plugin.
Volar
TypeScript Vue Plugin

Auto completion

Package Sidebar

Install

npm i vue3-window-events

Weekly Downloads

2

Version

0.0.3

License

MIT

Unpacked Size

86.1 kB

Total Files

8

Last publish

Collaborators

  • kadiryazici