vue_ipc
A IPC Render Plugin for vue + electron, you can simply communicate with electron main process, just like ajax。
Install
npm run install vue_ipc# or yarn add vue_ipc
Usage
Firstly, import your Vue project:
// main.js ; + Vue; VueconfigproductionTip = false; router store
You can use $ipcRenderer
object to send and listen message:
name: "Home" { return loading: false error: null ; } { // send message to main process+ this$ipcRenderer; // listen response message from main process + this$ipcRenderer; };
The edit Electron main.js/background.js
,like this:
;; const API_ADDRESS = "https:www.xxx.com/api"; ipcMain
Methods
Method | type | Description |
---|---|---|
send | func | Send message to electron main process from render process, accept method ,URL ,body three arguments |
once | func | listen message from electron main process to render process, accept a signal argument and a callback function |
Send Function Arguments
Name | type | Description |
---|---|---|
method | String | Normal HTTP Request methods |
URL | String | api url |
body | Object | This is an optional argument,if you use GET method,you can ignore it |