当前位置:网站首页>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
边栏推荐
- There is only one switch, how to realize the nqa of master-slave automatic switching
- 链表中的数字相加----链表专题
- The Seven Weapons of Programmers
- 无题七
- 2022.8.3
- 【LeetCode】623. Add a row to the binary tree
- Science bosses say | Hong Kong rhubarb KaiBin teacher take you unlock the relationship between the matrix and 6 g
- 无题一
- PAT Class B-B1019 Digital Black Hole (20)
- C语言的高级用法
猜你喜欢
随机推荐
偏向锁/轻量锁/重级锁锁锁更健康,上锁解锁到底是怎么完成实现的
CCVR eases heterogeneous federated learning based on classifier calibration
Concurrent CAS
Science bosses say | Hong Kong rhubarb KaiBin teacher take you unlock the relationship between the matrix and 6 g
Example of Noise Calculation for Amplifier OPA855
seata源码解析:事务状态及全局锁的存储
Oracle临时表空间作用
Happens-before rules for threads
C语言的高级用法
自定义过滤器和拦截器实现ThreadLocal线程封闭
Neuron Newsletter 2022-07|新增非 A11 驱动、即将支持 OPC DA
Embedded practice ---- based on RT1170 transplant memtester to do SDRAM test (25)
seata源码解析:TM RM 客户端的初始化过程
thinkPHP5 realizes clicks (data increment/decrement)
IO流篇 -- 基于io流实现文件夹拷贝(拷贝子文件夹及子文件夹内文件)满满的干货
Two-table query average grouping in sql server
欧盟 | 地平线 2020 ENSEMBLE:D2.13 SOTIF Safety Concept(上)
交换机端口的三种类型详解与hybrid端口实验
Comprehensively explain what is the essential difference between GET and POST requests?Turns out I always misunderstood
Xcode10的打包方式distribute app和启动项目报错以及Xcode 打包本地ipa包安装到手机上