dva的技术脉络

这里是我的培训视频

链接:https://pan.baidu.com/s/1ITMT-3e-rL1FRVQ6YDoBRw?pwd=2fuk
提取码:2fuk

  • 和umi好基友的关系,很容易适配,建项目就内置了
  • 以umi项目为例

models 文件夹下默认是数据模型

申明一个 task.ts

export default {
  namespace: 'task',
  state: {
    //搜索框
    SearchForm:{
    TaskName:"",
    TaskCode:"",
    TaskStatus:"",
    },
    //分页组件
    PageInfo:{
    pageSize:"10",
    total:0,
    Current:1
    },
    //用于渲染表格的数据
    DataSource:[],
    DictInfo:{
     CityList:[{Name:"上海",id:1},{Name:"北京",id:2}],
     TaskStatus:[{Name:"运行中",value:"1"}]
  },
  effects:{
    //初始化字典
    * initPageInfo({ payload }, { call, put }) {
      const response = yield call(initPageInfo, payload);
      yield put({
        type: 'saveinitDictInfo',
        payload: response,
      });
    },
  },//从后台取数据,native交互,操作事件
  reducers:{
      saveinitDictInfo(state, { payload }) {
      return produce(state, (draftState: any) => {
        draftState.dictinfo = {
          ...payload.data,
        }
      });
    },
  },//本地内存计算事件
 },
  
搜索框
//订阅数据,形成本地的props
@connect(({ task, loading }: any) => ({
  SearchForm: task.SearchForm,
  loading: loading,
}))

//改变数据怎么?

 const { dispatch } = props;
  dispatch({
          type: 'task/Search',
          payload: record,
});

//获取loading
 !!this.props.loading.effects['task/Search']

数据列表

//订阅数据,形成本地的props
@connect(({ task, loading }: any) => ({
  PageInfo: task.PageInfo,
  DataSource: task.DataSource,
  loading: loading,
}))

//改变数据怎么?

 const { dispatch } = props;
  dispatch({
          type: 'task/Search',
          payload: record,
});

//获取loading
 !!this.props.loading.effects['task/Search']

 

posted on 2022-06-12 21:37  漫思  阅读(27)  评论(0编辑  收藏  举报

导航