当前位置:网站首页>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
边栏推荐
- 【Excel实战】--图表联动demo_001
- openpyxl to manipulate Excel files
- 七夕浪漫约会不加班,RPA机器人帮你搞定工作
- EU | Horizon 2020 ENSEMBLE: D2.13 SOTIF Safety Concept (Part 2)
- 无题五
- IDEA执行Test操作导致数据插入时出现了重复数据
- openpyxl操作Excel文件
- seata源码解析:TM RM 客户端的初始化过程
- Qiu Jun, CEO of Eggplant Technology: Focus on users and make products that users really need
- 交换机端口的三种类型详解与hybrid端口实验
猜你喜欢
施一公:科学需要想象,想象来自阅读
Creo 9.0 基准特征:基准平面
15.1.1、md—md的基础语法,快速的写文本备忘录
Example of Noise Calculation for Amplifier OPA855
周报2022-8-4
js graphics operation one (compatible with pc, mobile terminal to achieve draggable attribute drag and drop effect)
只有一台交换机,如何实现主从自动切换之nqa
偏向锁/轻量锁/重级锁锁锁更健康,上锁解锁到底是怎么完成实现的
seata源码解析:TM RM 客户端的初始化过程
Why do I recommend using smart async?
随机推荐
Creo 9.0 基准特征:基准坐标系
为什么我推荐使用智能化async?
Going to book tickets tomorrow, ready to go home~~
开源一夏|OpenHarmony如何查询设备类型(eTS)
程序员的七种武器
CPU的亲缘性affinity
无题十三
【zeno】为zeno增加子模块/新节点的最小化的例子
PAT乙级-B1020 月饼(25)
Voice conversion相关语音数据集综合汇总
Hundred lines of code launch red hearts, why programmers lose their girlfriends!
我的杂记链接
周报2022-8-4
PAT乙级-B1019 数字黑洞(20)
tensorflow.keras cannot introduce layers
2022.8.3
无题十四
How to realize the short press and long press detection of the button?
leetcode points to Offer 10- I. Fibonacci sequence
自定义过滤器和拦截器实现ThreadLocal线程封闭