当前位置:网站首页>Architecture part -- the use of UMI framework and DVA
Architecture part -- the use of UMI framework and DVA
2022-06-25 23:40:00 【BetterGG】
First, declare : This is a result of umi + antdesign + dva Constituent items , This section mainly describes , Build one to do Components + Request interface data + Data management model + mock data The concise 、 science 、 Effective logical structure , And how to achieve it , What are the advantages of it .
The directory structure is as follows :

customer/list/index.jsx:

action/customer.js file :

models/customer.js

services/customer.js:

mock/user.js:

The above sequence is arranged according to the logical sequence of data activities
- Here comes the user customer/list/index.js ( chart 2) This interface
- The hook function called action/customer.js ( chart 3) The method in
- Triggered models/customers.js ( chart 4) Asynchronous functions in *fetchList
- adopt call() Method , Trigger services/customer.js ( chart 5) Medium request Request to get the data and return it here to response( notes : Here can be requested mock data , It can also be the data of the requested real interface )
- And then through put() Methods the trigger Synchronization function saveList() , Save the data to state in
- stay customer/list/index.js( chart 2) In the interface , adopt connect Methods will state Data is associated with components , Make this component available for state data , A complete data flow is formed .
Be careful : Above request yes umi The framework's own request method , It's sealed , stay src/utils/request in
- Precautions and advantages
- The file name of each process node required by a data activity should be the same , Easy to read and understand , Such as customer.js stay action、models、services、mock This name is all under the folder
- action Constant is defined in , As mentioned above CUSTOMER Constant , The advantage is that when called in a build , stay models This value is in the namespace under , If there is any modification , Just change this constant , convenient
- Above request yes umi The framework's own request method , It's sealed , stay src/utils/request in
- shortcoming
- At present, I feel that the biggest drawback is ,dva Data stream processing is done using generation Packaged , At present, the mainstream idea is Promise, Out of the mainstream , May be used later generation There are fewer and fewer front-end developers , High cost of later maintenance . Here you are 2 An account generation And promise The article :generation And promise,Async、Promise and Generator
边栏推荐
- C1. k-LCM (easy version)-Codeforces Round #708 (Div. 2)
- 18亿像素火星全景超高清NASA放出,非常震撼
- Download the latest V80 version of Google Chrome
- The simplest screen recording to GIF gadget in history, licecap, can be tried if the requirements are not high
- Hibernate core api/ configuration file / L1 cache details
- 解决‘tuple‘ object has no attribute ‘lower‘
- Episode 3: thread synchronization using thread lock
- 史上最简单的录屏转gif小工具LICEcap,要求不高可以试试
- php性能优化
- When are the three tools used for interface testing?
猜你喜欢

What is Unified Extensible Firmware Interface (UEFI)?

QT Chinese and English use different fonts respectively

Hibernate core api/ configuration file / L1 cache details

Online customer service - charging standards and service provision of third parties

Rk3568+ Hongmeng industrial control board industrial gateway video gateway solution

excel如何实现中文单词自动翻译成英文?这个公式教你了

Pycharm student's qualification expires, prompting no suitable licenses associated with account solution

UE4 学习记录一 创建角色,并控制其移动

Kotlin空指针Bug

森林的先序和中序遍历
随机推荐
CSDN force value
Graduation trip | recommended 5-day trip to London
YUV444、YUV422、YUV420、YUV420P、YUV420SP、YV12、YU12、NV12、NV21
cookie、session、token
Idea auto generator generates constructor get/set methods, etc
Efr32bg22 ble module (low power Bluetooth communication module) at command test
[Axi] interpretation of Axi protocol atomic access
自定义QComboBox下拉框,右对齐显示,下拉列表滑动操作
Share a downloaded osgeo4w64 Library Based on qgis3.10
Day4 branch and loop summary and operation
After xampp restarts, the MySQL service cannot be started.
MySQL自定义函数实例
CAD中图纸比较功能怎么用
YUV444、YUV422、YUV420、YUV420P、YUV420SP、YV12、YU12、NV12、NV21
CSDN原力值
B. Box Fitting-CodeCraft-21 and Codeforces Round #711 (Div. 2)
qtcreator 格式化代码
Xinchida nd04 nd04c nrf52832 (52810) ble module (low power Bluetooth communication module) at command test
23class introduction
(serial port Lora module) centrida rf-al42uh private protocol test at instruction test communication process