fix error

This commit is contained in:
Jay 2017-04-13 13:13:40 +08:00
parent e5bf72435c
commit efdc7e01c2
2 changed files with 10 additions and 8 deletions

View File

@ -89,6 +89,7 @@ class LocStatus extends React.Component{
render (){ render (){
let {i18n} = this.props; let {i18n} = this.props;
console.log(this.state.list);
return ( return (
<Container fluid> <Container fluid>
<Segment className="clearfix"> <Segment className="clearfix">

View File

@ -7,11 +7,12 @@
* @return {string} * @return {string}
*/ */
export const padding = (str, lng = 0, arrow = -1, txt = '0') => { export const padding = (str, lng = 0, arrow = -1, txt = '0') => {
if(typeof str != 'string') str = str.toString(); if (!str) str = '';
if(typeof txt != 'string') txt = txt.toString(); if (typeof str != 'string') str = str.toString();
if(!isFinite(lng) || lng <= 0) return str; if (typeof txt != 'string') txt = txt.toString();
if(str.length < lng) return padding(arrow < 0 ? `${txt}${str}` : `${str}${txt}`, lng, arrow, txt); if (!isFinite(lng) || lng <= 0) return str;
return str; if (str.length < lng) return padding(arrow < 0 ? `${txt}${str}` : `${str}${txt}`, lng, arrow, txt);
return str;
} }
/** /**
@ -21,7 +22,7 @@ export const padding = (str, lng = 0, arrow = -1, txt = '0') => {
* @return {string} * @return {string}
*/ */
export const convertTime = (timestamp, showSec = false) => { export const convertTime = (timestamp, showSec = false) => {
timestamp = padding(timestamp, 13, 1, '0'); timestamp = padding(timestamp, 13, 1, '0');
let d = new Date(parseInt(timestamp)); let d = new Date(parseInt(timestamp));
return `${d.getFullYear()}-${padding(d.getMonth() + 1, 2)}-${padding(d.getDate(), 2)} ${padding(d.getHours(), 2)}:${padding(d.getMinutes(), 2)}${showSec ? `:${padding(d.getSeconds(), 2)}` : ''}` return `${d.getFullYear()}-${padding(d.getMonth() + 1, 2)}-${padding(d.getDate(), 2)} ${padding(d.getHours(), 2)}:${padding(d.getMinutes(), 2)}${showSec ? `:${padding(d.getSeconds(), 2)}` : ''}`
} }