亚洲中字慕日产2020,大陆极品少妇内射AAAAAA,无码av大香线蕉伊人久久,久久精品国产亚洲av麻豆网站

資訊專欄INFORMATION COLUMN

工作流程

Chiclaim / 985人閱讀

摘要:引入引入組件和綁定結(jié)構(gòu)頁(yè)面組件這個(gè)組件引入做連接引入中的函數(shù)到中處理數(shù)據(jù)獲取中的數(shù)據(jù)組件上會(huì)受到發(fā)來(lái)的數(shù)據(jù)包含發(fā)來(lái)的信息定義函數(shù)定義字段字符串定義的函數(shù)返回一個(gè)高階函數(shù)傳入和再到處理數(shù)據(jù)出字段和函數(shù)供和組件使用類型的請(qǐng)求或者不需要將數(shù)

main.js

1.引入Route,createStore,combineReducers

const {Router, Route, Redirect, IndexRoute, browserHistory} = ReactRouter;
const {Provider, connect} = ReactRedux;
const { createStore, combineReducers, applyMiddleware, compose} = Redux;
const {syncHistoryWithStore, routerMiddleware, routerReducer, push } = ReactRouterRedux;
const thunkMiddleware = require("redux-thunk");

2.引入組件和reducer

const DanbaiPacket = require("Containers/DanbaiPacket");
const DanbaiPacket = require("Containers/DanbaiPacket");

3.綁定reducer,store

const reducer = combineReducers({
  routing: routerReducer,
  localizationReducer: LocalizationReducer,
  accountReducer: AccountReducer,
  notificationReducer: NotificationReducer,
  headlineDetailReducer: HeadlineDetailReducer,
  headlineEditorReducer: HeadlineEditorReducer,
  headlineListReducer: HeadlineListReducer,
  userCollectionsReducer: UserCollectionsReducer,
  userArticlesReducer: UserArticlesReducer,
  signInPopupReducer: SignInPopupReducer,
  notifyMessageReducer: NotifyMessageReducer,
  redPacketReducer: RedPacketReducer,
  danbaiPacketReducer: DanbaiPacketReducer
});

const middleware = routerMiddleware(browserHistory);
let initState = {};

let store = createStore(
    reducer,
    {},
    compose(
      applyMiddleware(thunkMiddleware, middleware),
      (window.RAILS_ENV === "development" && window.devToolsExtension) ? window.devToolsExtension() : f=>f
    )
);

4.Router結(jié)構(gòu)

var routes = (
  
    
      
        
        
        
        
          
          
        
        
        
      
    
  
);
頁(yè)面組件

1.define這個(gè)組件
引入routerAction, connect做reducer連接
引入action中的函數(shù)getDanbaiPacket,dispatch到action中處理數(shù)據(jù)
this.props獲取reducer中的數(shù)據(jù)
組件上componentWillReceiveProps會(huì)受到reducer發(fā)來(lái)的數(shù)據(jù),nextProps包含發(fā)來(lái)的信息.

define("Containers/DanbaiPacket", function(require, exports) {
  const { routerActions } = ReactRouterRedux;
  const { connect } = ReactRedux;
  const { getDanbaiPacket } = require("Actions/DanbaiPacketAction");

  var DanbaiPacket = React.createClass({
    getInitialState: function() {
      return {

      };
    },
    componentDidMount: function() {
      this.props.dispatch(getDanbaiPacket(this.props.params.id));
    },
    render: function() {
      const { localization, current_account, danbaiPacketDetail } = this.props;
      
      return (
        
aaa
); } }); function mapStateToProps(state, ownProps) { return { localiztion: state.localizationReducer.languages[state.localizationReducer.languages.current], current_account: state.accountReducer.current_account, danbaiPacketDetail: state.danbaiPacketReducer.danbaiPacketDetail }; } return connect(mapStateToProps)(connect(null, routerActions)(DanbaiPacket)); });

2.action
定義Action函數(shù)
定義type字段字符串
定義dispatch的函數(shù),返回一個(gè)高階函數(shù),傳入dispatch和getState,再dispatch到reducer處理數(shù)據(jù)
return出type字段和函數(shù),供reducer和組件使用.
post類型的請(qǐng)求,或者不需要將數(shù)據(jù)掛載到reducer函數(shù)上的,不需要dispatch到reducer處理,直接用callback處理返回的數(shù)據(jù).

//= require ../../util/fetch_posts
//= require ./notify_message_action

define("Actions/DanbaiPacketAction", function(require, exports) {
  const fetch = require("util/FetchPosts");
  const { addNotifyMesaage } = require("Actions/NotifyMessageAction");
  const INIT_DANBAI_PACKET = "INIT_DANBAI_PACKET";

  function initDanbaiPacket(data) {
    return {
      type: INIT_DANBAI_PACKET,
      data: data
    };
  }

  function getDanbaiPacket(id, callback) {
    return (dispatch, getState) => {
      fetch.get({
        url: "/api/events/" + id + ",json",
        dataType: "json",
        data: {
          sonkwo_client: "web"
        },
        success: function(res) {
          dispatch(initDanbaiPacket(res))
        },
        error: function(xhr) {
          if (xhr.status === 404) {
            dispatch(addNotifyMesaage("wufazhaodaoziyuan"));
          }
        }
      });
    }
  }

  return {
    INIT_DANBAI_PACKET,
    getDanbaiPacket
  }
});

3.reducer
從action引入type字符串
定義reducer函數(shù),即可以在組件中被獲取的數(shù)據(jù)
每個(gè)reducer函數(shù)都會(huì)return出一個(gè)對(duì)象,這就是這個(gè)函數(shù)的值,要用Object.assign({}, state, action.data)
state的值會(huì)變化,直接action.data的話,那就只有這一個(gè)值.
可以用Object.assign({}, state, {rules: action.data}),
這樣掛載再reducer函數(shù)上的key為rules.
只要掛載再reducer函數(shù)上的key值有變化,只要有dispatch,就會(huì)觸發(fā)組件render
即使有兩個(gè)reducer處理函數(shù),也是以dispatch為準(zhǔn),dispatch后會(huì)觸發(fā)reducer處理函數(shù),觸發(fā)組件render.

//= require ../actions/danbai_packet_action

define("Reducers/DanbaiPacketReducer", function(require, exports) {
  const { INIT_DANBAI_PACKET } = require("Actions/RedPacketAction");
  const { combineReducers } = Redux;

  function danbaiPacketDetial(state={}, action) {
    switch (action.type) {
      case INIT_DANBAI_PACKET:
        return Object.assign({}, state, action.data);
      default:
        return state;
    }
  }

  return combineReducers({
    danbaiPacketDetial: danbaiPacketDetial
  });
});

4.子組件
define子組件
使用解構(gòu)賦值,給rules初始值
也可以使用componentWillReceiveProps

define("Components/Example", function(require, exports) {
  var Example = React.createClass({
    getInitialState: function() {
      return {

      };
    },
    componentWillReceiveProps: function() {

    },
    componentDidMount: function() {

    },
    render: function() {
      const { rules = [] } = this.props;

      return (
        
example { rules.map((item, index) => { return (
id: { item.id }, type: { item.type }
) }) }
); } }); return Example; });

在父組件中引入,傳入danbaiPacketDetail.rules

問(wèn)題總結(jié)

1.所有請(qǐng)求都把數(shù)據(jù)掛在了reducer函數(shù)上,且都直接返回,造成數(shù)據(jù)雜糅,key值沖突,不易處理邏輯,
又造成重復(fù)render.
解決:

1.post請(qǐng)求或者不需要處理返回?cái)?shù)據(jù)的,直接callback執(zhí)行回掉,在action中不需要dispatch到reducer處理.
2.reducer處理數(shù)據(jù)時(shí),return出來(lái)的值整個(gè)值,使用Object.assign({}, state, action.data),把數(shù)據(jù)
全部返回.

2.Modal的ErrorPopup只需要有一個(gè),error為this.state.error,mode為"simple"則樣式自己寫.
層疊順序?yàn)?SignInPopup > ErrorPopup > 自身的modal
3.this.props.params.id,this.props.location.query只能在Route中的組件獲取.
4.對(duì)每個(gè)接口做錯(cuò)誤處理.
5.對(duì)一些可能先返回undefined的值做保護(hù),可以用解構(gòu)賦值初始值.

const {a = []} = this.props;

6.post之后一般有回調(diào),再重新dispatch獲取接口,或者直接在post接口中callbackc處理.

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://www.ezyhdfw.cn/yun/84260.html

相關(guān)文章

  • Activiti就是這么簡(jiǎn)單

    摘要:介紹什么是是由軟件在年月日發(fā)布的業(yè)務(wù)流程管理框架,它是覆蓋了業(yè)務(wù)流程管理工作流服務(wù)協(xié)作等領(lǐng)域的一個(gè)開(kāi)源的靈活的易擴(kuò)展的可執(zhí)行流程語(yǔ)言框架。第二部分是表示表的用途的兩個(gè)字母標(biāo)識(shí)。 Activiti介紹 什么是Activiti? Activiti5是由Alfresco軟件在2010年5月17日發(fā)布的業(yè)務(wù)流程管理(BPM)框架,它是覆蓋了業(yè)務(wù)流程管理、工作流、服務(wù)協(xié)作等領(lǐng)域的一個(gè)開(kāi)源的、靈...

    everfly 評(píng)論0 收藏0
  • 使用Python批量處理工作簿和工作

    摘要:使用批量處理工作簿和工作表批量新建并保存工作簿批量打開(kāi)一個(gè)文件夾中的打開(kāi)工作簿批量重命名一個(gè)工作簿的所有工作表批量重命名多個(gè)工作簿批量重命名多個(gè)工作簿中的同名工作表將一個(gè)工作簿的所有工作表批量復(fù)制到其他工作簿按條件將一 ...

    maxmin 評(píng)論0 收藏0
  • Activiti工作流從入門到入土:完整Hello World大比拼(Activiti工作流 API

    摘要:通過(guò)流程引擎獲取了一個(gè)對(duì)象倉(cāng)庫(kù)對(duì)象由倉(cāng)庫(kù)的服務(wù)對(duì)象產(chǎn)生一個(gè)部署對(duì)象配置對(duì)象,用來(lái)封裝部署操作的相關(guān)配置。輔導(dǎo)員審批的審批人員是歐陽(yáng)思海。部署流程定義從與流程定義和部 文章源碼托管:https://github.com/OUYANGSIHA...歡迎 star !??! 本來(lái)想著閑來(lái)無(wú)事,前面在項(xiàng)目中剛剛用到了工作流 Activiti 框架,寫寫博客的,但是,事情總是紛紛雜雜,一直拖延到現(xiàn)...

    ghnor 評(píng)論0 收藏0
  • 請(qǐng)不要怪罪流程

    摘要:但流程不是死的,尤其在互聯(lián)網(wǎng)公司,只要有助于我們的目標(biāo)達(dá)成,那么流程只是一陣東風(fēng)。工作中并不是所有事情都可以依賴流程去保證萬(wàn)無(wú)一失。所以不要怪罪流程,這并不是流程的問(wèn)題,而是人的問(wèn)題。所以請(qǐng)不要再怪罪流程啦,以人為本,才是長(zhǎng)久之計(jì)。 本文由作者周巧芬授權(quán)網(wǎng)易云社區(qū)發(fā)布。 筆者所在的團(tuán)隊(duì)這段時(shí)間正在兩個(gè)版本的交接期,前一個(gè)版本馬上要上線了,但后一個(gè)版本的需求早在三周前就已經(jīng)啟動(dòng),卻遲遲沒(méi)...

    MiracleWong 評(píng)論0 收藏0
  • PHPOA辦公系統(tǒng):新型工作流引擎4.0,快速提升OA辦公方式

    摘要:更嚴(yán)重的是,會(huì)導(dǎo)致信息系統(tǒng)的失控。實(shí)現(xiàn)了數(shù)據(jù)的同步交換和共享,從而簡(jiǎn)化多余流程,消除重復(fù)工作,有效提升工作效率和精度。工作流將大大深化系統(tǒng)的應(yīng)用,讓系統(tǒng)發(fā)揮出全新的價(jià)值。而不具有工作流特點(diǎn)的系統(tǒng),將很快被時(shí)代所拋棄。 一、工作流1.0時(shí)代終結(jié)OA系統(tǒng)的應(yīng)用正在不斷深化,正在逐漸完成從無(wú)紙化到智能化的轉(zhuǎn)變,作為OA系統(tǒng)應(yīng)用的核心,工作流技術(shù)也同樣發(fā)生了很大的轉(zhuǎn)變。 我們知道,對(duì)工作流比較...

    afishhhhh 評(píng)論0 收藏0
  • Activiti工作流從入門到入土:工作流簡(jiǎn)介

    摘要:基于許可的開(kāi)源平臺(tái),創(chuàng)始人是的項(xiàng)目架構(gòu)師,它特色是提供了插件,開(kāi)發(fā)人員可以通過(guò)插件直接繪畫出業(yè)務(wù)流程圖。二工作流引擎對(duì)象,這是工作的核心。五總結(jié)工作流的概念就先介紹這么多了,更多的去官網(wǎng)查看,下一節(jié)將用一個(gè)入門的實(shí)例來(lái)對(duì)工作流進(jìn)行講解。 文章源碼托管:https://github.com/OUYANGSIHA...歡迎 star ?。。?一、activiti介紹 Activiti5是由...

    Mr_houzi 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<