Problems in the use of dva-loading

  1. models/order.js is the model file of the component
  2. configure loading in index.js
import createLoading from "dva-loading"
app.use(createLoading({
    globale: false,
    models: {
        order: false
    }
}))

the problem is that there may be multiple interfaces in models/order.js, and multiple state, may have multiple components such as Table,Card in views/order. Each component uses the loading attribute, using mode

.
render(){
    const {loading} = this.props
    // ....
    return (
        <Table loading= {loading.global}/>
        <Card loading = {loading.global} />
    )
}

clipboard.png

if the API is called again in Card, the Card in region C is similar to Tab,Tab and will re-initiate the request when clicked. The problem is that when the Tab switch initiates the request, the loading in area An and B will be reset, from true to false. Please give us some advice on how to solve it. Thank you!

Mar.22,2021

loading can be refined into the effect, in each model, such as order model, where there are three effect, corresponding to the AMagi BMagol C region. The loading correspondence can be loading.effects ['order/fetchOrder'], loading.effects [' order/fetchOrderTran'], loading.effects ['order/fetchOrderOps']. So they don't affect each other.

Menu