当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
长达四年的减肥记录
明天去订票,准备回家咯~~
新白娘子传奇系列
CVPR 2022 | 将X光图片用于垃圾分割,港中大(深圳)探索大规模智能垃圾分类
2022-08-01 Review the basic binary tree and operations
交换机端口的三种类型详解与hybrid端口实验
leetcode: 529. 扫雷游戏
使用HBuilder离线本地打包ipa教程
CCVR基于分类器校准缓解异构联邦学习
MySQL使用聚合函数可以不搭配GROUP BY分组吗?
并发之CAS
MQTT X Newsletter 2022-07 | 自动更新、MQTT X CLI 支持 MQTT 5.0、新增 conn 命令…
dotnet OpenXML parsing PPT charts Getting started with area charts
Neuron Newsletter 2022-07|新增非 A11 驱动、即将支持 OPC DA
【LeetCode】623. Add a row to the binary tree
链表中的数字相加----链表专题
请问大佬们 ,使用 Flink SQL CDC 是不是做不到两个数据库的实时同步啊
请问如果想往mysql里面写数据,直接用flink-connector-jdbc就可以吧,可是我在f
Happens-before rules for threads
2022.8.3









