[英]Coming from jQuery, how does one do DOM animations in React.js? Such as animate a progress Bar?
[英]How to add Ajax progress bar to React.js application?
我有一個 submitForm(); 發送 Ajax 請求並返回數據的函數。 如何在我的程序中顯示進度條。
我正在使用 jQuery 發送 Ajax。
沒有提到第三方庫(有很多有 API 供您調用來為您完成)
最簡單的方法是dispatch
類似isLoading
Action 的東西,同時觸發 API 調用。 然后讓你想要的組件訂閱商店的那部分,並顯示你喜歡的任何內容。 所以你可以有render()
代碼看起來像
if(this.props.isLoading){
return <span> Loading... </span> //or whatever progress bar you want
}
else{
//your code
}
然后當您的 API 響應時,您只需將isLoading
設置回 false,然后您的組件就可以使用這些響應。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.