记录写时间组件的过程

自作多情 提交于 2020-02-16 14:30:38

1.当前时间各种格式

用了momentjs

官网http://momentjs.cn/

2.定时器

created(){
    this.updateMin();
    this.updateDay();
    this.timeInterval=setInterval(this.updateMin,1000);
    this.dayInterval=setInterval(this.updateDay,1000*6);
}
beforeDestroy() {
    clearInterval(this.timeInterval);
    clearInterval(this.dayInterval);
}

https://www.cnblogs.com/xiaohuochai/p/5773183.html

3. const let var区别

https://www.cnblogs.com/ksl666/p/5944718.html

4.农历

抄抄改改好久,最后还是直接使用了github的一个轮子

https://github.com/jjonline/calendar.js

调用另一个JS文件中的函数

import lunar from './calendar';
this.lunarDate = lunar.myLunar(...)

导入的js文件中,要有导出

function myLunar(y, m, d) {
    ...
}

export default {
    myLunar
}

//--------or---------
export function lineOption(option, data){
    //...
    return data;
}

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!