Coder Social home page Coder Social logo

physika-web's Introduction

physika_web

配置安装

把项目clone到本地目录

git clone https://github.com/cenyc/Physika-web.git

进入clone文件目录

cd Physika-web

安装所需到node_modules

npm install

使用webpack打包项目

npm run build

运行项目

node .\src_server\app.js

在浏览器访问http://localhost:8888 即可

问题记录

API


ES6 and CommonJS(当前版本无需参考)

  • 如果使用commonjs模式,在packge.json中加入

"type": "module",

  • 自定义module(commonjs规范)
function test(req, res) {
    console.log('finish');
    res.end();
}
module.exports.test = test;
  • 一定要搞清楚什么是ES6commonjs,ES6是浏览器运行的js,commonjs是node端可以直接运行的js。通常用mjs表示ES6规范,以此加以区分。
ES6--以module为标准--以export导出接口--以import引入模块;
commonjs--以module.exports导出--以require引入模块;

node --es-module-specifier-resolution=node test.mjs

  • 在CommonJS规范的代码中使用ES6 module
第一步:安装babel
 npm install @babel/core @babel/register @babel/preset-env --save-dev

第二步:编写fun.mjs
function aa() {
    console.log('this is aa write in ES6');
}

function bb() {
    console.log('this is bb write in ES6');
}
export {aa,bb}

第三步:编写start.js,使用babel转换fun.mjs
require('@babel/register')({
    presets: ['@babel/preset-env']
});

module.exports = require('./fun');

第四步:在CommonJS中require需要的模块,并调用
var start = require('./src/start');
start.aa();
start.bb();

express

  • express中,结束访问要添加

res.end();

physika-web's People

Contributors

liyunfei18 avatar cenyc avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

szmybs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.