• Vue 定时执行函数


        <script>
            new Vue({
                el: '#app',
                data() {
                    return {
                        clock: '',
                    }
                },
                mounted() {
                    this.$nextTick(() => {
                        setInterval(this.CurentTime, 1000);
                    })
                },
                methods: {
                    CurentTime() {
                        var getTime = new Date();
                        var year = getTime.getFullYear(); //
                        var month = getTime.getMonth() + 1; //
                        var day = getTime.getDate(); //
                        var hh = getTime.getHours(); //
                        var mm = getTime.getMinutes(); //
                        var ss = getTime.getSeconds(); //
                        var clock = year + "-";
                        if (month < 10)
                            clock += "0";
                        clock += month + "-";
    
                        if (day < 10)
                            clock += "0";
    
                        clock += day + " ";
    
                        if (hh < 10)
                            clock += "0";
    
                        clock += hh + ":";
    
                        if (mm < 10) clock += '0';
                        clock += mm + ":";
    
                        if (ss < 10) clock += '0';
                        clock += ss;
    
                        this.clock = clock
                    }
    
                },
            })
        </script>
  • 相关阅读:
    allocator类
    智能指针shared_ptr
    字面值常量类
    转换构造函数
    委托构造函数
    访问说明符&封装
    const成员函数
    函数指针
    constexper和常量表达式
    函数返回数组指针
  • 原文地址:https://www.cnblogs.com/lwming/p/11495151.html
Copyright © 2020-2023  润新知