window-plugin
v1.0.4
Published
This module adds $window and $document properties to Vue components.
Downloads
2
Maintainers
Readme
The Vue WindowPlugin adds $window and $document DOM objects to each Vue component. This is helpful when accessing DOM from attribute templates. allowing you to call DOM methods without declaring a method.
For example, you can open alerts, log events, or open URLs in new tabs.
Usage
<button @click='$window.alert("You clicked a button.")'>Click Me</button>
<button @click='$window.console.log("A button was clicked.")'>Click Me</button>
<button @click='$window.open("https://www.quickchords.org/", "_blank"))'>Click Me</button>
<h1 :v-text='$document.title' />
Installation
Install the package via NPM
npm install --save window-plugin
Install the plugin before creating your Vue
import Vue from 'vue'
import WindowPlugin from 'window-plugin'
Vue.use(WindowPlugin)
new Vue({
// your code here
})
Dependencies
None