公用方法列表

searchAssign的用法

import Utils from 'UtilsFolder/utils';
let x = { data: 1, num: 2 };
    Utils.searchAssign(x, {
      data: 3,
      qwer: 3
    });
    console.log(x, 'zl');

在这里插入图片描述

getDate日期获取

 import Utils from 'UtilsFolder/utils';
 let { Y, M, D, h, min, s } = Utils.getDate(new Date());
    console.log(Y, M, D, h, min, s);//2020 0 3 13 36 33

date2string日期获取

   import Utils from 'UtilsFolder/utils';
    let x = Utils.date2string(new Date(), '---', false);
    console.log(x, 'x');//2020---01---03 13:42:07 //最后一个参数为true
    console.log(x, 'x');//13:42:07 //最后一个参数为false

showMsg

import { showMsg } from 'ActionsFolder/CommonActions';
const { showMsg } = this.props
showMsg('结束时间应该小于等于今天');
const mapDispatchToProps = (dispatch) => {
  return {
    showMsg: bindActionCreators(showMsg, dispatch)
   };
};

比较时间compareTime

console.log(Utils.compareTime('2019-1-1 00:00:00', '2020-1-1 00:00:00'));
//true
console.log(Utils.compareTime('2019-1-1', '2020-1-1'));
//true
发布了49 篇原创文章 · 获赞 2 · 访问量 1475

猜你喜欢

转载自blog.csdn.net/formylovetm/article/details/103817462