JavaScript简介

来源:互联网 发布:excel建立数据库 编辑:程序博客网 时间:2024/05/22 09:06

用JavaScript写个桌面级应用

  • 打开cmd运行npm init创建 package.json文件(和node的基本一样)
  • 然后执行一次npm install –save-dev electron-prebuilt
  • 在根目录下创建main.js
  • 然后在app下创建index.html文件
  • 配置VS Code启动环境

    先装全局:glup: npm install gulp -g//全局安装gulp(前端自动化工具,只是为了方便)

    再装本地:npm install –save-dev gulp

  • 安装 electron-packager:npm install –save-dev electron-packager
  • 在项目根目录下面的 package.json 里添加代码:

    “packager”: “electron-packager ./app HelloWorld –all –out ./xxApp –version 1.4.6 –overwrite –icon=./app/img/icon/icon.ico”

  • 使用命令npm run-script packager(打包)

Introduction to JavaScript

  • There are three essential data types in JavaScript: **strings, numbers, and boolean**s.
  • We can write out anything to the console with console.log.
  • We can do math with operators like +, -, *, and /.
  • We can find the remainder after dividing two numbers with a modulus: %.
  • We can generate a random number with Math.random, then make it a whole number with Math.floor.
  • We write a single line comment with // and a multi-line comment with /* and */

Variables

  • How to create variables:var.
  • How to change a variable’s value.
  • How to interpolate, or insert, a variable into a string.

Control flow

  • if/else statements make binary decisions and execute separate code based on a condition.
  • We can add extra conditions with to if/else statements with else if conditions.
  • switch statements make complicated if/else statements easier to read, however they achieve the same result as if/else statements.
  • Comparison operators, like <, >, <=, and >= can compare two variables. After they compare, they always return either true or false.
  • Logical Operators, like &&, ||, !==, and !, can compare two variables to see if a certain condition exists:
    • && checks if both sides are true.
    • || checks if either side is true.
    • !== checks if both sides are not equal.
    • ! changes a variable that is true to false, and vice versa.

参考文献:

1.用JavaScript写个桌面级应用

0 0
原创粉丝点击