{"id":8884,"date":"2024-05-23T16:01:01","date_gmt":"2024-05-23T08:01:01","guid":{"rendered":""},"modified":"2024-05-23T16:01:01","modified_gmt":"2024-05-23T08:01:01","slug":"react \u540e\u7aef\u6846\u67b6_\u4ec0\u4e48\u662f\u6846\u67b6","status":"publish","type":"post","link":"https:\/\/mushiming.com\/8884.html","title":{"rendered":"react \u540e\u7aef\u6846\u67b6_\u4ec0\u4e48\u662f\u6846\u67b6"},"content":{"rendered":"

\n <\/path> \n<\/svg> <\/p>\n

\u524d\u8a00<\/h3>\n

\u597d\u4e45\u6ca1\u6709\u5199\u6587\u7ae0\u4e86\uff0c\u56e0\u4e3a\u6700\u8fd1\u6bd4\u8f83\u5fd9\uff0c\u4e5f\u6ca1\u65f6\u95f4\u5199\u5f00\u6e90\u9879\u76ee\uff0c\u6700\u8fd1\u62bd\u51fa\u4e86\u4e00\u70b9\u65f6\u95f4\u6539\u5584 IceE \u8fd9\u4e2a\u9879\u76ee\uff0c\u5199\u4e00\u7bc7\u6559\u7a0b\u4f9b\u5927\u5bb6\u4f7f\u7528\u5427
github\uff1ahttps:\/\/github.com\/IceEmblem\/IceE<\/p>\n

IceE \u662f\u4ec0\u4e48\uff1f<\/h3>\n
\n

\u672c\u6587\u4f7f\u7528\u7684\u662f icetf 0.3.1 \u7248\u672c\uff0c\u4e0d\u540c\u7248\u672c\u4ee3\u7801\u7a0d\u6709\u5dee\u522b<\/p>\n<\/blockquote>\n

\u5927\u591a\u6570\u7684\u4f01\u4e1aWeb\u7ad9\u70b9\u548c\u79fb\u52a8RNApp\u90fd\u4f1a\u6709\u76f8\u540c\u7684JS\u903b\u8f91\uff08\u6bd4\u5982\u4e0b\u5355\u7684\u9a8c\u8bc1\uff0c\u652f\u4ed8\u7684\u9a8c\u8bc1\u7b49\uff09\uff0c\u90a3\u4e48\u6211\u4eec\u8981\u7ef4\u62a42\u4efd\u4e00\u6a21\u4e00\u6837\u7684\u4ee3\u7801\u5417\uff1fIceE \u5c31\u662f\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u4f60\u53ef\u4ee5\u5c06\u516c\u5171\u7684JS\u4ee3\u7801\u5206\u79bb\u5230\u516c\u5171\u7684 package \u4e2d\uff0c\u4e0b\u9762\u662fIceE\u7684\u6846\u67b6\u7ed3\u6784\uff0c\u770b\u4e86\u8fd9\u4e2a\u7ed3\u6784\uff0c\u4f60\u5e94\u8be5\u731c\u5230 ice-core \u5c31\u662f\u90a3\u4e2a\u516c\u5171\u7684 package
\"react<\/p>\n

\u5feb\u901f\u5f00\u59cb<\/h3>\n
    \n
  1. \n

    \u4e0b\u9762\u9879\u76ee\uff1agit clone https:\/\/github.com\/IceEmblem\/IceE.git<\/p>\n<\/li>\n

  2. \n

    \u5b89\u88c5\u5305\uff1ayarn install<\/p>\n<\/li>\n

  3. \n

    \u8fd0\u884c
    Web \u7aef\uff1ayarn start:web
    android \u7aef\uff1ayarn start:android
    ios \u7aef\uff1ayarn start:ios<\/p>\n<\/li>\n<\/ol>\n

    \u5b89\u88c5\u4e00\u4e2a\u73b0\u6709\u7684\u6a21\u5757<\/h3>\n
      \n
    1. \u8fdb\u5165 \/packages\/ice-react-start \u76ee\u5f55\uff0c\u6267\u884c yarn add ice-react-test \u5b89\u88c5 ice-react-test \u6a21\u5757\u3002<\/li>\n
    2. \u8bbf\u95ee \/Test \u5c31\u80fd\u770b\u5230 ice-react-test \u63d0\u4f9b\u7684\u9875\u9762\u4e86\u3002<\/li>\n<\/ol>\n
      \n

      \u6ce8\uff1aIceE
      \u7684\u6a21\u5757\u5728\u6846\u67b6\u542f\u52a8\u65f6\u4f1a\u521d\u59cb\u5316\u8be5\u6a21\u5757\uff0c\u6a21\u5757\u53ef\u4ee5\u5411\u6846\u67b6\u6ce8\u518c\u4ed6\u7684\u529f\u80fd\uff0c\u6bd4\u5982\u9875\u9762\uff0c\u4e3b\u9898\u7b49\uff0c\u4f60\u5b89\u88c5\u540e\u8bbf\u95ee\u5230\u8be5\u6a21\u5757\u63d0\u4f9b\u7684\u9875\u9762\u6216\u4e3b\u9898\u7b49\u529f\u80fd\uff0c\u4f60\u65e0\u9700\u7f16\u5199\u4e00\u884c\u4ee3\u7801<\/p>\n<\/blockquote>\n

      \u5c1d\u8bd5\u7f16\u5199\u4e00\u4e2a\u6a21\u5757<\/h3>\n

      \u901a\u8fc7\u5982\u4e0b\u6559\u7a0b\u5b8c\u6210 mymodule \u6a21\u5757\u7684\u7f16\u5199<\/p>\n

      1. \u7b80\u5355\u7684\u6a21\u5757<\/strong>
      1\uff09\u6267\u884c node icee cw mymodule \u547d\u4ee4\uff0c\u751f\u6210 mymodule \u6a21\u5757\uff0c\u751f\u6210\u6210\u529f\u540e packages \u4e0b\u9762\u4f1a\u591a\u51fa\u4e00\u4e2a\u6587\u4ef6\u5939\uff0c\u8fd9\u5c31\u662f\u6211\u4eec\u7684\u6a21\u5757\u4e86
      \"react
      2\uff09\u6267\u884c yarn install \u5b89\u88c5\u4f9d\u8d56<\/p>\n

      3\uff09\u73b0\u5728\u6211\u4eec\u5c06 Module.js \u4ee3\u7801\u6539\u4e3a\u5982\u4e0b\uff1a
      \u8be5\u4ee3\u7801\u5411\u6846\u67b6\u6ce8\u518c\u4e00\u4e2a\u9875\u9762<\/p>\n

      import<\/span> React from<\/span> 'react'<\/span>\nimport<\/span> { \n   <\/span>BaseModule,<\/span> PageProvider,<\/span> ModuleFactory,<\/span> Page}<\/span> from<\/span> 'icetf'<\/span>\nimport<\/span> { \n   <\/span>Module as<\/span> CoreModule}<\/span> from<\/span> 'ice-core'<\/span>;<\/span>\n\nexport<\/span> default<\/span> class<\/span> Module<\/span> extends<\/span> BaseModule<\/span>\n{ \n   <\/span>\n    initialize<\/span>(<\/span>)<\/span>{ \n   <\/span>\n        \/\/ \u6ce8\u518c\u9875\u9762\uff0c\u8bbf\u95ee \/mymodule \u5c06\u663e\u793a\u8fd9\u4e2a\u9875\u9762<\/span>\n        PageProvider.<\/span>register<\/span>(<\/span>new<\/span> Page<\/span>(<\/span>\"mymodule\"<\/span>,<\/span> \"\/mymodule\"<\/span>,<\/span> (<\/span>props)<\/span> =><\/span> <<\/span>div><\/span>Hello MyModule!<\/span>!<\/span>!<\/span><<\/span>\/<\/span>div><\/span>)<\/span>)<\/span>;<\/span>\n    }<\/span>\n}<\/span>\n\nModuleFactory.<\/span>register<\/span>(<\/span>Module,<\/span> [<\/span>CoreModule]<\/span>)<\/span>;<\/span>\n<\/code><\/pre>\n

      4\uff09\u6267\u884c yarn start:web \u8fd0\u884c\u7ad9\u70b9\uff0c\u8bbf\u95ee \/mymodule \u9875\u9762\uff0c\u5c31\u53ef\u4ee5\u770b\u5230\u6211\u4eec\u6ce8\u518c\u7684\u9875\u9762\u4e86
      \"react<\/p>\n

      2. \u5e94\u7528redux<\/strong><\/p>\n

      \u73b0\u5728\u6211\u4eec\u6765\u5e94\u7528 redux\uff0cIceE \u5bf9 redux \u8fdb\u884c\u4e86\u5c01\u88c5\uff0c\u5982\u679c\u4e0d\u6e05\u695a redux\uff0c\u8bf7\u67e5\u770b\u5b98\u7f51\u6587\u6863\u3002<\/p>\n

      1\uff09\u65b0\u5efa\u4e00\u4e2aReduxs\u6587\u4ef6\u5939
      \"react
      \u5176\u4e2d\u5305\u542b3\u4e2a\u6587\u4ef6
      Action.js: \u5b58\u653e\u6211\u4eec\u7684 action \u7c7b\u578b\u548c createAction \u51fd\u6570\uff0c\u5982\u4e0b<\/p>\n

      \/\/ \u52a0<\/span>\nexport<\/span> const<\/span> Add =<\/span> \"Add\"<\/span>;<\/span>\nexport<\/span> function<\/span> createAdd<\/span>(<\/span>num)<\/span> { \n   <\/span>\n    return<\/span> { \n   <\/span>\n        type:<\/span> Add,<\/span>\n        num:<\/span> num\n    }<\/span>\n}<\/span>\n\n\/\/ \u51cf<\/span>\nexport<\/span> const<\/span> Subtract =<\/span> \"Subtract\"<\/span>;<\/span>\nexport<\/span> function<\/span> createSubtract<\/span>(<\/span>num)<\/span> { \n   <\/span>\n    return<\/span> { \n   <\/span>\n        type:<\/span> Subtract,<\/span>\n        num:<\/span> num\n    }<\/span>\n}<\/span>\n<\/code><\/pre>\n

      Reducer.js: \u5b58\u653e\u6211\u4eec\u7684 reducer\uff0c\u5982\u4e0b<\/p>\n

      import<\/span> { \n   <\/span>Add,<\/span> Subtract}<\/span> from<\/span> '.\/Actions'<\/span>\n\nexport<\/span> function<\/span> reducer<\/span>(<\/span>state =<\/span> { \n   <\/span> num:<\/span> 0<\/span> }<\/span>,<\/span> action)<\/span> \n{ \n   <\/span>\n    if<\/span>(<\/span>action.<\/span>type ==<\/span> Add)<\/span>{ \n   <\/span>\n        return<\/span> { \n   <\/span>\n            num:<\/span> state.<\/span>num +<\/span> action.<\/span>num\n        }<\/span>\n    }<\/span>\n\n    if<\/span>(<\/span>action.<\/span>type ==<\/span> Subtract)<\/span>{ \n   <\/span>\n        return<\/span> { \n   <\/span>\n            num:<\/span> state.<\/span>num -<\/span> action.<\/span>num\n        }<\/span>\n    }<\/span>\n\n    return<\/span> state;<\/span>\n}<\/span>\n<\/code><\/pre>\n

      MyRedux.js: \u8be5\u7c7b\u5c31\u76f8\u5f53\u4e0e\u547d\u540d\u7a7a\u95f4\uff0c\u65f6\u6211\u4eec\u7684 acion \u548c\u5176\u4ed6\u6a21\u5757\u7684 action \u4e0d\u51b2\u7a81\uff0c\u5176\u4ee3\u7801\u5f88\u7b80\u5355\uff0c\u5982\u4e0b<\/p>\n

      import<\/span> { \n   <\/span> BaseIceRedux }<\/span> from<\/span> 'icetf'<\/span>;<\/span>\nimport<\/span> { \n   <\/span> reducer }<\/span> from<\/span> \".\/Reducer\"<\/span>;<\/span>\n\nclass<\/span> Redux<\/span> extends<\/span> BaseIceRedux<\/span> { \n   <\/span>\n    reducer =<\/span> reducer;<\/span>\n\n    constructor<\/span>(<\/span>)<\/span> { \n   <\/span>\n        \/\/ \u547d\u540d\uff0c\u7528\u4e8e\u533a\u5206\u5176\u4ed6\u6a21\u5757\u7684 action<\/span>\n        super<\/span>(<\/span>\"My\"<\/span>)<\/span>;<\/span>\n    }<\/span>\n}<\/span>\n\nexport<\/span> default<\/span> new<\/span> Redux<\/span>(<\/span>)<\/span>;<\/span>\n<\/code><\/pre>\n

      2\uff09\u5728Module\u4e2d\u6ce8\u518c\u6211\u4eec\u7684 reducer<\/p>\n

      import<\/span> { \n   <\/span>BaseModule,<\/span> ModuleFactory,<\/span> IEStore}<\/span> from<\/span> 'icetf'<\/span>\nimport<\/span> { \n   <\/span>Module as<\/span> CoreModule}<\/span> from<\/span> 'ice-core'<\/span>;<\/span>\nimport<\/span> MyRedux from<\/span> '.\/Reduxs\/MyRedux'<\/span>\n\nexport<\/span> default<\/span> class<\/span> Module<\/span> extends<\/span> BaseModule<\/span> { \n   <\/span>\n    initialize<\/span>(<\/span>)<\/span> { \n   <\/span>\n        \/\/ \u6ce8\u518c\u5f53\u524d\u6a21\u5757\u7684 reducer<\/span>\n        IEStore.<\/span>register<\/span>(<\/span>MyRedux)<\/span>;<\/span>\n    }<\/span>\n}<\/span>\n\nModuleFactory.<\/span>register<\/span>(<\/span>Module,<\/span> [<\/span>CoreModule]<\/span>)<\/span>;<\/span>\n<\/code><\/pre>\n

      3\uff09\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528 redux
      \u73b0\u5728\u6211\u4eec\u7f16\u5199\u4e00\u4e2a\u9875\u9762
      \"react
      \u5176\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n

      import<\/span> React from<\/span> 'react'<\/span>\nimport<\/span> MyRedux from<\/span> '..\/Reduxs\/MyRedux'<\/span>\nimport<\/span> { \n   <\/span>createAdd,<\/span> createSubtract}<\/span> from<\/span> '..\/Reduxs\/Actions'<\/span>\n\nclass<\/span> MyPage<\/span> extends<\/span> React.<\/span>Component<\/span> { \n   <\/span>\n    render<\/span>(<\/span>)<\/span> { \n   <\/span>\n        return<\/span> <<\/span>div><\/span>\n            <<\/span>div><\/span>\u603b\u6570\uff1a{ \n   <\/span>this<\/span>.<\/span>props.<\/span>num}<\/span><<\/span>\/<\/span>div><\/span>\n            { \n   <\/span>\/* \u52a01\u6309\u94ae *\/<\/span>}<\/span>\n            <<\/span>button onClick=<\/span>{ \n   <\/span>(<\/span>)<\/span> =><\/span> { \n   <\/span>\n                this<\/span>.<\/span>props.<\/span>add<\/span>(<\/span>1<\/span>)<\/span>;<\/span>\n            }<\/span>}<\/span>><\/span>+<\/span>1<\/span><<\/span>\/<\/span>button><\/span>\n            { \n   <\/span>\/* \u51cf1\u6309\u94ae *\/<\/span>}<\/span>\n            <<\/span>button onClick=<\/span>{ \n   <\/span>(<\/span>)<\/span> =><\/span> { \n   <\/span>\n                this<\/span>.<\/span>props.<\/span>subtract<\/span>(<\/span>1<\/span>)<\/span>;<\/span>\n            }<\/span>}<\/span>><\/span>-<\/span>1<\/span><<\/span>\/<\/span>button><\/span>\n        <<\/span>\/<\/span>div><\/span>\n    }<\/span>\n}<\/span>\n\n\/\/ redux \u7684 mapStateToProps<\/span>\n\/\/ state \u5c31\u662f\u5f53\u524d\u6a21\u5757\u7684 state<\/span>\nconst<\/span> mapState<\/span> =<\/span> (<\/span>state,<\/span> props)<\/span> =><\/span> { \n   <\/span>\n    return<\/span> state;<\/span>\n}<\/span>\n\n\/\/ redux \u7684 mapDispatchToProps<\/span>\nconst<\/span> mapDispost<\/span> =<\/span> (<\/span>dispatch,<\/span> props)<\/span> =><\/span> { \n   <\/span>\n    return<\/span> { \n   <\/span>\n        add:<\/span> (<\/span>num)<\/span> =><\/span> { \n   <\/span>\n            return<\/span> dispatch<\/span>(<\/span>createAdd<\/span>(<\/span>num)<\/span>)<\/span>;<\/span>\n        }<\/span>,<\/span>\n        subtract:<\/span> (<\/span>num)<\/span> =><\/span> { \n   <\/span>\n            return<\/span> dispatch<\/span>(<\/span>createSubtract<\/span>(<\/span>num)<\/span>)<\/span>;<\/span>\n        }<\/span>\n    }<\/span>\n}<\/span>\n\n\/\/ \u4f7f\u7528 MyRedux \u7684 connect \u751f\u6210\u7ec4\u4ef6<\/span>\nexport<\/span> default<\/span> MyRedux.<\/span>connect<\/span>(<\/span>mapState,<\/span> mapDispost)<\/span>(<\/span>MyPage)<\/span>\n<\/code><\/pre>\n

      4\uff09\u5728module\u4e2d\u6ce8\u518c\u9875\u9762<\/p>\n

      import<\/span> { \n   <\/span>BaseModule,<\/span> ModuleFactory,<\/span> IEStore,<\/span> PageProvider,<\/span> Page}<\/span> from<\/span> 'icetf'<\/span>\nimport<\/span> { \n   <\/span>Module as<\/span> CoreModule}<\/span> from<\/span> 'ice-core'<\/span>;<\/span>\nimport<\/span> MyRedux from<\/span> '.\/Reduxs\/MyRedux'<\/span>\nimport<\/span> MyPage from<\/span> '.\/MyPage'<\/span>\n\nexport<\/span> default<\/span> class<\/span> Module<\/span> extends<\/span> BaseModule<\/span> { \n   <\/span>\n    initialize<\/span>(<\/span>)<\/span> { \n   <\/span>\n        \/\/ \u6ce8\u518c\u5f53\u524d\u6a21\u5757\u7684 reducer<\/span>\n        IEStore.<\/span>register<\/span>(<\/span>MyRedux)<\/span>;<\/span>\n        \/\/ \u6ce8\u518c\u9875\u9762<\/span>\n        PageProvider.<\/span>register<\/span>(<\/span>new<\/span> Page<\/span>(<\/span>\"MyPage\"<\/span>,<\/span> \"\/MyPage\"<\/span>,<\/span> MyPage)<\/span>)<\/span>;<\/span>\n    }<\/span>\n}<\/span>\n\nModuleFactory.<\/span>register<\/span>(<\/span>Module,<\/span> [<\/span>CoreModule]<\/span>)<\/span>;<\/span>\n<\/code><\/pre>\n

      5\uff09\u8bbf\u95ee \/MyPage \u5c31\u80fd\u770b\u5230\u6211\u4eec\u7684\u9875\u9762\u4e86
      \"react
      3. \u6ce8\u518c\u4e2d\u95f4\u4ef6<\/strong>
      \u73b0\u5728\u6211\u4eec\u6ce8\u518c\u4e00\u4e2a\u6253\u5370 redux action \u7684\u4e2d\u95f4\u4ef6<\/p>\n

      1\uff09\u7f16\u5199\u4ee3\u7801
      \"react
      \u5176\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n

      \/\/ \u6ce8\u518c\u4e00\u4e2a Redux \u4e2d\u95f4\u4ef6<\/span>\nexport<\/span> default<\/span> (<\/span>store)<\/span> =><\/span> (<\/span>next)<\/span> =><\/span> (<\/span>action)<\/span> =><\/span> { \n   <\/span>\n    console.<\/span>log<\/span>(<\/span>action)<\/span>;<\/span>\n    return<\/span> next<\/span>(<\/span>action)<\/span>\n}<\/span>\n<\/code><\/pre>\n

      2\uff09\u5728module\u4e2d\u6ce8\u518c\u4e2d\u95f4\u4ef6<\/p>\n

      import<\/span> { \n   <\/span>BaseModule,<\/span> ModuleFactory,<\/span> IEStore,<\/span> PageProvider,<\/span> Page,<\/span> MiddlewareFactory}<\/span> from<\/span> 'icetf'<\/span>\nimport<\/span> { \n   <\/span>Module as<\/span> CoreModule}<\/span> from<\/span> 'ice-core'<\/span>;<\/span>\nimport<\/span> MyRedux from<\/span> '.\/Reduxs\/MyRedux'<\/span>;<\/span>\nimport<\/span> MyPage from<\/span> '.\/MyPage'<\/span>;<\/span>\nimport<\/span> LogMiddlewares from<\/span> '.\/Middlewares\/LogMiddlewares'<\/span>\n\nexport<\/span> default<\/span> class<\/span> Module<\/span> extends<\/span> BaseModule<\/span> { \n   <\/span>\n    initialize<\/span>(<\/span>)<\/span> { \n   <\/span>\n        \/\/ \u6ce8\u518c\u5f53\u524d\u6a21\u5757\u7684 reducer<\/span>\n        IEStore.<\/span>register<\/span>(<\/span>MyRedux)<\/span>;<\/span>\n        \/\/ \u6ce8\u518c\u9875\u9762<\/span>\n        PageProvider.<\/span>register<\/span>(<\/span>new<\/span> Page<\/span>(<\/span>\"MyPage\"<\/span>,<\/span> \"\/MyPage\"<\/span>,<\/span> MyPage)<\/span>)<\/span>;<\/span>\n        \/\/ \u6ce8\u518c\u4e2d\u95f4\u4ef6<\/span>\n        MiddlewareFactory.<\/span>register<\/span>(<\/span>LogMiddlewares)<\/span>;<\/span>\n    }<\/span>\n}<\/span>\n\nModuleFactory.<\/span>register<\/span>(<\/span>Module,<\/span> [<\/span>CoreModule]<\/span>)<\/span>;<\/span>\n<\/code><\/pre>\n

      3\uff09\u67e5\u770b\u6548\u679c
      \"react<\/p>\n

      fetch \u7684\u5c01\u88c5<\/h3>\n

      Icetf \u5bf9 fetch \u8fdb\u884c\u4e86\u4e00\u4e2a\u5c01\u88c5\uff0c\u5176\u5c01\u88c5\u7c7b\u4e3aIceFetch\uff0cice-core \u7684 Module \u6587\u4ef6\u505a\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b<\/p>\n

      preInitialize<\/span>(<\/span>)<\/span>{ \n   <\/span>\n    \/\/ \u6ce8\u518c fetch \u540e\u9762\u53ef\u4ee5\u4f7f\u7528 IceFetch \u8fdb\u884c\u7f51\u7edc\u8bf7\u6c42<\/span>\n    \/\/ fetchData: fetch \u8bf7\u6c42\u7684\u6570\u636e<\/span>\n    \/\/ \u8fd4\u56de\u503c: Promise<Response><\/span>\n    IceFetch.<\/span>registerFetch<\/span>(<\/span>(<\/span>fetchData:<\/span> any)<\/span> =><\/span> { \n   <\/span>\n        return<\/span> fetch<\/span>(<\/span>fetchData.<\/span>url,<\/span> fetchData.<\/span>header)<\/span>\n    }<\/span>)<\/span>;<\/span>\n\n    \/\/ \u6ce8\u518c\u4e00\u4e2a\u7ed3\u679c\u5904\u7406\u5668\uff0c\u4f7f\u7528 IceFetch \u8bf7\u6c42\u7684\u7ed3\u679c\u4f1a\u5148\u901a\u8fc7\u8be5\u5904\u7406\u5668\u5904\u7406<\/span>\n    \/\/ responst: fetch \u8bf7\u6c42\u7ed3\u679c<\/span>\n    \/\/ fetchData: fetch \u8bf7\u6c42\u7684\u6570\u636e<\/span>\n    \/\/ actionType: redux \u7684 action \u7c7b\u578b<\/span>\n    \/\/ \u8fd4\u56de\u503c: \u5904\u7406\u540e\u7684\u6570\u636e\uff0c\u4f1a\u4f5c\u4e3a\u4e0b\u4e00\u4e2a handler \u7684 responst<\/span>\n    IceFetch.<\/span>registerHandler<\/span>(<\/span>(<\/span>responst:<\/span> Response,<\/span> fetchData:<\/span> any,<\/span> actionType:<\/span> string)<\/span> =><\/span> { \n   <\/span>\n        return<\/span> responst;<\/span>\n    }<\/span>)<\/span>\n}<\/span>\n<\/code><\/pre>\n

      registerFetch: \u5f53\u524d\u4f7f\u7528\u7684\u8bf7\u6c42\u51fd\u6570\u3002
      registerHandler: \u8bf7\u6c42\u63a5\u53d7\u540e\u7684\u5904\u7406\u5668\u3002<\/p>\n

      IceFetch\u63d0\u4f9b\u7684\u7f51\u7edc\u8bf7\u6c42\u51fd\u6570<\/strong>
      1\uff09IceFetch.createThunkAction(fetchData: any, actionType: string)
      \u7528\u4e8e\u751f\u6210\u5f02\u6b65 action\uff0cfetchData \u539f\u6837\u8f6c\u7ed9\u6ce8\u518c\u7684 fetch \u51fd\u6570\uff0c\u5728\u8bf7\u6c42\u65f6 IceFetch \u5411 redux \u5206\u53d1 \u201cIEFecth_Request\u201d \u7c7b\u578b\u7684 action\uff0c\u5728\u63a5\u6536\u540e IceFetch \u5411 redux \u5206\u53d1 actionType \u7c7b\u578b\u7684 action\uff0c\u5728\u51fa\u9519\u540e\uff0cIceFetch \u5411 redux \u5206\u53d1 \u201cIEFecth_Error\u201d \u7c7b\u578b\u7684 action\u3002
      2\uff09IceFetch.ieReduxFetch(fetchData: any)
      ieReduxFetch \u662f\u4e00\u4e2a\u7f51\u7edc\u8bf7\u6c42\u51fd\u6570\uff0c\u4e0d\u662f\u4e00\u4e2a createAction \u51fd\u6570\uff0c\u5176\u901a\u8fc7 createThunkAction \u751f\u6210\u5f02\u6b65 action \u5e76\u76f4\u63a5\u53d1\u751f\u7ed9 redux \uff0c\u5176\u4f7f\u7528\u7684 actionType \u7c7b\u578b\u4e3a \u201cIEFecth_Receive\u201d<\/p>\n","protected":false},"excerpt":{"rendered":"react \u540e\u7aef\u6846\u67b6_\u4ec0\u4e48\u662f\u6846\u67b6\u524d\u8a00\u597d\u4e45\u6ca1\u6709\u5199\u6587\u7ae0\u4e86\uff0c\u56e0\u4e3a\u6700\u8fd1\u6bd4\u8f83\u5fd9\uff0c\u4e5f\u6ca1\u65f6\u95f4\u5199\u5f00\u6e90\u9879\u76ee\uff0c\u6700\u8fd1\u62bd\u51fa\u4e86\u4e00\u70b9\u65f6\u95f4\u6539\u5584IceE\u8fd9\u4e2a\u9879\u76ee...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/8884"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=8884"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/8884\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=8884"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=8884"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=8884"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}