当前位置:网站首页>Egg framework usage (1)
Egg framework usage (1)
2022-08-05 09:32:00 【front grass seed】
Table of Contents
egg initialization steps
1. Go to the project folder taobao and run cmd
2. Enter npm init egg --type=simple egg framework initialization
Get the following files:

3. There will still be some modules missing: enter npm i to download
The result is:

4. Download is complete npm run dev Start the server

Analysis: The default port number of the egg frame is: 7001 . You can also enter the real ip of the machine: 192.168.x.xx:7001
5. Browser input http://127.0.0.1:7001/ or http://192.168.0.105/ will appear

This is the URL that the framework has registered for users in advance

Analysis: When the pathname entered by the user is / or does not enter the pathname, it will run the index function in the home file in the controller folder

If pathname is entered casually: it will appear

Note: The front-end and back-end interactions use JSON data, even if the data returned by the back-end to the front-end is an object or other style data, it is actually JSON data. In the future, the front-end will beUsing axios to make a network request will convert the JSON data '{"name":"Hello","age":"20"}' into an object: {name:'Hello', age:20}

egg folder recognition

Analysis: All static files in the public folder have their own URLs, so there is no need to register with router.get
p>
egg convention rules
1 app/router.js: used to configure URL routing rules;
2 app/controller/ : used to parse the user's input, and return the corresponding result after processing;
3 app/service/: used to write business logic layer;
4 app/public/: for placing static resources; (static hosting)
5 config/config.{env}.js: used to write configuration files;
6 config/plugin.js is used to configure the plugins that need to be loaded;
egg official website
https://eggjs.org
边栏推荐
猜你喜欢

CPU的亲缘性affinity

Seata source code analysis: initialization process of TM RM client

欧盟 | 地平线 2020 ENSEMBLE:D2.13 SOTIF Safety Concept(上)

使用HBuilder离线本地打包ipa教程

Creo 9.0 基准特征:基准点

express hot-reload

交换机端口的三种类型详解与hybrid端口实验

15.1.1、md—md的基础语法,快速的写文本备忘录

ECCV 2022 Oral 视频实例分割新SOTA:SeqFormer&IDOL及CVPR 2022 视频实例分割竞赛冠军方案...

轩辕实验室丨欧盟EVITA项目预研 第一章(四)
随机推荐
egg框架使用(一)
tensorflow.keras无法引入layers
ECCV 2022 Oral Video Instance Segmentation New SOTA: SeqFormer & IDOL and CVPR 2022 Video Instance Segmentation Competition Champion Scheme...
Tanabata romantic date without overtime, RPA robot helps you get the job done
PAT Level B - B1021 Single Digit Statistics (15)
无题十一
seata源码解析:TM RM 客户端的初始化过程
无题三
无题九
openpyxl to manipulate Excel files
How ali cloud storage database automatically to speed up the loading speed of www.cxsdkt.cn how to set up the case?
sql server中 两表查询 平均数 分组
施一公:科学需要想象,想象来自阅读
随时牵手 不要随意分手[转帖]
无题六
Does flink cdc support synchronization from oracle dg library?
深度学习21天——卷积神经网络(CNN):天气识别(第5天)
蚁剑webshell动态加密连接分析与实践
Undefined symbols for architecture arm64解决方案
seata源码解析:事务状态及全局锁的存储