elelctron-store 是很好的本地储存库
https://www.npmjs.com/package/electron-store
npm i elelctron-store
在项目根路径下新增 vue.config.js
module.exports={
pluginOptions: {
electronBuilder: {
nodeIntegration: true
}
},
}
<template>
<div></div>
</template>
<script>
import Store from "electron-store";
const store = new Store();
store.set('hello','word')
store.get('hello')
// word
export default {
components: {},
data() {
return {
};
},
methods: {
},
mounted() {},
destroyed() {},
}
</script>
<style scoped>
</style>
在 electron 主进程中执行以下代码
import Store from "electron-store";
Store.initRenderer()
否则会报错 Electron Store: You need to call '.initRenderer()'from the main process.