Tag: universal

momentjs – fromNow()方法在通用(同构)的js应用程序中

我有一个应用程序是用node.js和react.js构build的,并且是通用的(或者是之前调用的“同构”),并且使用REST API来获取数据。 在某些组件的render方法中,我以2 days ago或few seconds ago格式显示date,在这种情况下,moment.js完美地工作。 我正在谈论它的方法fromNow() ,例如: render() { const { date } = this.props; const formattedDate = moment(date).fromNow(); return ( <div>{formattedDate}</div> ); } 但是这是问题: Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on […]