创建项目
vue init simulatedgreg/electron-vue my-project
cd my-project
yarn # or npm install
yarn run dev # or npm run dev
建议使用yarn或者cnpm
常见问题
- 依赖包下载失败,使用cnpm下载,或者直接到对应网址下载源码到相应文件夹
- 项目报错ReferenceError: process is not defined,解决方法有两个,第一个方法就是可以选择安装10版本的node,该版本是不会出现这个问题的。第二个方法就是将.electron-vue下面的webpack.renderer.config.js和webpack.web.config.js中添加下面的语句。
templateParameters(compilation, assets, options) {
return {
compilation: compilation,
webpack: compilation.getStats().toJson(),
webpackConfig: compilation.options,
htmlWebpackPlugin: {
files: assets,
options: options
},
process,
};
},
创建组件和路由的配置都是和vue一样的
引入element-ui
npm i element-ui -S
然后在main.js中引入
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);
最大化禁用
// 在main.js中 加入transparent: true
mainWindow = new BrowserWindow({
height: 563,
useContentSize: true,
width: 1000,
transparent: true
})