當我想發送一個請求時,直接在fetch函數里寫不就好了么,為什么要多一步中間件呢?const mapDispatchToProps = ( dispatch )=>({ fetchAndRenderArticle( articleName ){ fetch(`http://localhost:3000/getFile?articleName=${articleName}`).then( res=> { return res.text(); }).then( articleContent =>{ dispatch({ type:'fetchAndRenderArticle', articleContent:articleContent }); }).catch( err=>{ console.log(err); }); }});
redux 異步中間件有什么意義呢?
慕田峪7331174
2018-11-14 15:14:44