【发布时间】:2016-07-08 08:00:37
【问题描述】:
我正在执行以下操作以使 require 在 <app></app> 中可见
index.html:
<script>
var electron = require('electron')
</script>
<app></app>
<script src="bundle.js"></script>
App.vue:
const ipc = electron.ipcRenderer
console.log(ipc)
但是我在使用 ESLint 时遇到了 un-used 和 un-defined var 错误,所以我决定这样做:
需要.js:
var electron = require('electron')
exports.electron = electron
index.html:
<script src="requires.js"></script>
</head>
<body>
<app></app>
<script src="bundle.js"></script>
但现在我收到此错误:requires.js:3 Uncaught ReferenceError: exports is not defined。
导出和导入电子require的正确方法是什么?
注意: 直接在 App.vue 中要求 electron 不起作用。 index.html中只能要求electron
【问题讨论】:
-
也许是
module.exports而不是exports?
标签: javascript node.js webpack vue.js electron