Javascript 在React中获取联机当前时间
如果我运行此命令并每秒从服务器获取当前时间,有什么缺点Javascript 在React中获取联机当前时间,javascript,reactjs,time,Javascript,Reactjs,Time,如果我运行此命令并每秒从服务器获取当前时间,有什么缺点 fetchCurrentTime() { fetch(this.getApiUrl()) .then(resp => resp.json()) .then(resp => { const currentTime = resp.dateString; this.setState({currentTime}) }) } 您可以使用此API获取当前联机
fetchCurrentTime() {
fetch(this.getApiUrl())
.then(resp => resp.json())
.then(resp => {
const currentTime = resp.dateString;
this.setState({currentTime})
})
}
您可以使用此API获取当前联机时间 或
newdate().getTime()代码>