electron-vue

electron开发技术路线

  • electron-vue
  • element-ui
  • scss

【ui】
https://blog.csdn.net/u013816465/article/details/82709177
https://element.eleme.cn/#/zh-CN/component/layout
【editor】
http://ckeditor.com/
https://www.tiny.cloud/
【可视化】
echarts:
https://www.echartsjs.com/examples/zh/index.html#chart-type-candlestick
v-charts:
https://v-charts.js.org/#/line
【url】
electron 到 electron-vue的目录变化
https://www.jb51.net/article/149312.htm
【窗口】
多窗口
electron-vue-windows
https://github.com/hxkuc/electron-vue-windows
https://javascript.ctolib.com/hxkuc-electron-vue-windows.html

1. 开始

# 安装 vue-cli 和 脚手架样板代码
npm install -g vue-cli
vue init simulatedgreg/electron-vue my-project

# 安装依赖并运行你的程序
cd my-project
yarn # 或者 npm install
yarn run dev # 或者 npm run dev

2. 使用element-ui

cnpm i element-ui -S

在src/renderer/main.js中修改如下:

import Vue from 'vue'
import axios from 'axios'
import ElementUI from 'element-ui';  // 新添加
import 'element-ui/lib/theme-chalk/index.css';  //新添加

import App from './App'
import router from './router'
import store from './store'
Vue.use(ElementUI);  // 新添加

if (!process.env.IS_WEB) Vue.use(require('vue-electron'))
Vue.http = Vue.prototype.$http = axios
Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  components: { App },
  router,
  store,
  template: '<App/>'
}).$mount('#app')

element-ui需要加入到白名单里面,需要修改.electron-vue/webpack.renderer.config.js

将:

let whiteListedModules = ['vue']
修改为:

let whiteListedModules = ['vue', 'element-ui']

问题解决

  1. process is not defined
    在这里插入图片描述
    解决办法:.electron-vue/webpack.web.config.js 和.electron-vue/webpack.renderer.config.js中修改
new HtmlWebpackPlugin({
      filename: 'index.html',
      template: path.resolve(__dirname, '../src/index.ejs'),
      templateParameters(compilation, assets, options) {
        return {
          compilation: compilation,
          webpack: compilation.getStats().toJson(),
          webpackConfig: compilation.options,
          htmlWebpackPlugin: {
            files: assets,
            options: options
          },
          process,
        };
      },
      minify: {
        collapseWhitespace: true,
        removeAttributeQuotes: true,
        removeComments: true
      },
      nodeModules: false
    }),

重启之后,就能正常显示
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值