美文网首页
react native常用方法整理(持续更新中 ... ):

react native常用方法整理(持续更新中 ... ):

作者: dequal | 来源:发表于2021-05-11 16:15 被阅读0次

1、关于时间戳转换日期:

const formatDate_t = (milliseconds, showWeek = true, showWeekMinute = true) => {
    if (!milliseconds) {
        return '-';
    }
    const date = new Date(milliseconds);
    const year = date.getFullYear();
    const month = date.getMonth() + 1;
    const day = date.getDate();
    const hour = date.getHours(); // 0-23
    const minutes = date.getMinutes();
    const weekDay = date.getDay();

    const showMonth = month < 10 ? `0${month}` : month;
    const showDay = day < 10 ? `0${day}` : day;
    const showHour = hour < 10 ? `0${hour}` : hour;
    const showMinute = minutes < 10 ? `0${minutes}` : minutes;

    const weekDays = [0, 1, 2, 3, 4, 5, 6];
    const weekDayText = ['日', '一', '二', '三', '四', '五', '六'];

    if (!showWeekMinute) {
        return `${year}-${showMonth}-${showDay}`;
    }
    if (!showWeek) {
        return `${year}/${showMonth}/${showDay} ${showHour}:${showMinute}`;
    }
    return `${year}/${showMonth}/${showDay} 星期${weekDayText[weekDays.indexOf(weekDay)]} ${showHour}:${showMinute}`;
};

2、grunt命令配置Env文件:

grunt config

3、grunt命令更新模块版本号:

grunt updateVersion

相关文章

网友评论

      本文标题:react native常用方法整理(持续更新中 ... ):

      本文链接:https://www.haomeiwen.com/subject/hnxndltx.html