zoukankan      html  css  js  c++  java
  • Electron 入门案例1

    1:package.json

    通过npm init生成package.json文件,内容如下:

    {
      "name": "t02",
      "version": "1.0.0",
      "description": "",
      "main": "app.js",
      "scripts": {
        "start": "electron ."
      },
      "dependencies": {
        "electron": "~1.6.2"
      },
      "devDependencies": {
        "electron": "~1.6.2"
      },
      "author": "",
      "license": "ISC"
    }

    2:app.js

    const electron = require('electron');
    const app = electron.app;
    const BrowserWindow = electron.BrowserWindow;
    
    app.on('ready', function() {
        mainWindow = new BrowserWindow({
             400,
            height: 300
        });
    
        mainWindow.loadURL('file://' + __dirname + '/app.html');
    
        mainWindow.on('closed', function() {
            mainWindow = null;
        });
    });

    3:app.html

    <!doctype html>
    <html>
    <head>
    <title>My First Electron App</title>
    <style type="text/css">
    body {
        margin: 0;
    }
    
    textarea {
        width: 100%;
        border: none;
        background: #eee;
        margin: 10px 0;
        padding: 0;
        outline: none;
    }
    </style>
    </head>
    <body>
    <textarea rows="10"></textarea>
    </body>
    </html>

    4:运行

    (1)安装node_modules

    D:electron_ws 02>npm install

    (2)运行

    D:electron_ws 02>electron .

  • 相关阅读:
    数组对象遍历新增属性
    watch监听数据的改变
    同一个数组查重
    SpringCloud搭建(二) 支付模块搭建
    SpringCloud搭建(一) 聚合父工程搭建
    线程池
    同步容器
    容器
    JVM学习
    线程---ThreadLocal
  • 原文地址:https://www.cnblogs.com/yshyee/p/6672909.html
Copyright © 2011-2022 走看看