Coder Social home page Coder Social logo

vue-countdown's Introduction

#use

template

     <countdown
        class="times"
        :startTime="startTime"
        :endTime="endTime"
        :format="format"
        @change="chountChange"
        @end="end"
    />
     内进行付款,若未进行支付则订单自动取消。

js
this.format = "{yy}{mn}月{dd}天{hh}小时{mm}分钟{ss}秒";
this.startTime =  new Date().getTime();
this.endTime = this.startTime + 60*1000*60*24*3000

chountChange({ dd, hh, mm, ss,ms,yy}) {
    let str = "{dd}天{hh}小时{mm}分钟{ss}秒";
    if (dd == 0) str = "{hh}小时{mm}分钟{ss}秒";
    if (hh == 0 && dd == 0) str = "{mm}分钟{ss}秒"
    if (mm == 0 && hh == 0 && dd == 0) str = "{ss}秒";
    if (str != this.format) this.format = str;
}
end(){

}
prop & event
startTime 默认本地当前时间戳 开始时间
endTime 毫秒 结束时间
format "{yy}年{mn}月{dd}天{hh}小时{mm}分钟{ss}秒" 剩余时间 按照当前最高时间单位解析 1月10天10小时 == {mn}月{dd}天{hh}小时 和 (如果是6月份)40天10小时=={dd}天{hh}小时 是相同的
change 每次计算的回调 1000毫秒 通知一次 这个可以随时更改所有的属性
end 倒计时结束

vue-countdown's People

Watchers

James Cloos avatar caoshiyuan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.