Code Monkey home page Code Monkey logo

egg-note's Introduction

egg-note

egg.js 是基于KOA的企业级框架

1. eggjs创建项目

使用脚手架:

  • $ npm i egg-init -g
  • $ egg-init egg-example --type=simple
  • $ cd egg-example
  • $ npm i
  • $ npm run dev //启动项目

2.eggjs的目录结构

  • app/router.js 用于编写路由规则(必须)
  • app/controller 用于处理用户输入(必须)
  • app/public 用于存放静态资源
  • app/middleware 用于编写中间件 -- 其余结构用到再说

router.js

  • app.get(url,controller) controller:可以写成 "home.index" 或 app.controller.home.index
  • app.redirect(url,anotherUrl) 重定向 可连接静态资源 有时会出问题(把浏览器的表单自动填充数据删掉就好了)

controller

  • ctx.body 服务器返回的数据
  • ctx.params get请求query里的数据
  • ctx.crul(url,options) 处理HTTP请求,options是设置请求头 请求回来的数据默认是buffer
    设置dataType为'json'

egg-note's People

Contributors

jsershadow avatar

Watchers

James Cloos avatar

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.