當(dāng)我想發(fā)送一個請求時,直接在fetch函數(shù)里寫不就好了么,為什么要多一步中間件呢?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 異步中間件有什么意義呢?
呼喚遠(yuǎn)方
2018-10-13 15:31:39