UNPKG

1.43 kBMarkdownView Raw
1# vue-electron
2> The vue plugin that wraps [electron](https://github.com/electron/electron) APIs to the Vue object.
3
4[![js-standard-style](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)
5
6### Need a full boilerplate for creating electron apps built with vue? Make sure to check out electron-vue.
7[https://github.com/SimulatedGREG/electron-vue](https://github.com/SimulatedGREG/electron-vue)
8
9## Installing
10Install using NPM
11```
12npm install vue-electron --save
13```
14
15Include using webpack or browserify
16
17**main.js**
18```js
19import Vue from 'vue'
20import VueElectron from 'vue-electron'
21
22Vue.use(VueElectron)
23```
24
25## Using the plugin
26This plugin will attach electron APIs to the Vue object itself, so accessing all APIs is dead simple. All official documentation from electron can be used and accessed from `this.$electron`.
27
28So instead of...
29```js
30const electron = require('electron')
31
32export default {
33 methods: {
34 getName () {
35 return electron.remote.app.getName()
36 }
37 }
38}
39```
40
41Now you can...
42
43```js
44export default {
45 methods: {
46 getName () {
47 return this.$electron.remote.app.getName()
48 }
49 }
50}
51```
52
53Now you might be thinking, "Is it really that annoying to simply require electron to access it?" Probably not, but it can get cumbersome to have to include it in every component file that needs it. In the end, attaching electron directly to Vue just makes sense.