iview-mpvue
  • 首页
  • 布局
    • Layout 栅格布局
    • Grid 宫格
    • Panel 面板
    • List 列表
    • Card 卡片
  • 基础组件
    • Button 按钮
    • Color 色彩
    • Icon 图标
  • 导航
    • TabBar 标签栏
    • Tabs 标签页
    • Drawer 抽屉
    • Page 分页
    • Steps 步骤条
    • NoticeBar 通告栏
    • Index 索引选择器
    • Sticky 吸顶容器
  • 操作反馈
    • ActionSheet 动作面板
    • Toast 轻提示
    • Modal 对话框
    • Message 全局提醒
    • Spin 加载中
    • Swipeout 滑动菜单
  • 视图
    • Badge 徽章
    • Alert 警告提示
    • Tag 标签
    • Progress 进度条
    • Avatar 头像
    • CountDown 倒计时
    • Divider 分隔符
    • Collapse 折叠面板
    • LoadMore 页底提示
  • 表单
    • Input 输入框
    • Radio 单选
    • Checkbox 复选
    • Switch 开关
    • Rate 评分
    • InputNumber 数字输入框
Powered by GitBook
On this page
  • 使用指南
  • 示例
  • API

Was this helpful?

  1. 视图

CountDown 倒计时

使用指南

在.vue中引入组件

<script>
    import iCountDown from 'iview-mpvue/dist/components/countDown/countDown'
    export default {
        components: {
            'i-count-down': iCountDown
        }
    }
</script>

在main.js中引入样式文件

import 'iview-mpvue/dist/components/countDown/style/css'

示例

<div class="div-wrap">
    <text class="type-title">倒计时:</text>
    <i-count-down
        :target="targetTime"
        :clear-timer="clearTimer"
    ></i-count-down>
</div>

<div class="div-wrap">
    <text class="type-title">显示天的倒计时:</text>
    <i-count-down
        :target="targetTime1"
        :show-day="true"
        :clear-timer="clearTimer"
    ></i-count-down>
</div>


<div class="div-wrap">
    <text class="type-title">自定义格式倒计时:</text>
    <i-count-down
        :target="targetTime"
        :format="myFormat"
        :clear-timer="clearTimer"
    ></i-count-down>
</div>

<div class="div-wrap">
      <text class="type-title">自定义格式倒计时:</text>
      <i-count-down
          :target="targetTime1"
          :show-day="true"
          :format="myFormat1"
          :clear-timer="clearTimer"
      ></i-count-down>
</div>

<div class="div-wrap">
      <text class="type-title">执行回调的倒计时:</text>
      <i-count-down
          :target="targetTime2"
          @callback="myLinsterner"
          :clear-timer="clearTimer"
      ></i-count-down>
      <text>倒计时状态:{{status}}</text>
</div>


<div class="div-wrap">
      <text class="type-title">修改倒计时样式:</text>
      <i-count-down
          :target="targetTime"
          countdown-class="big"
          :clear-timer="clearTimer"
      ></i-count-down>
</div>
<script>
export default {
    ...
    data() {
        return {
            targetTime: 0,
            targetTime1: 0,
            targetTime2: 0,
            myFormat: ['时', '分', '秒'],
            myFormat1: ['天', '时', '分', '秒'],
            status: '进行中...',
            clearTimer: false
        }
    },
    onLoad() {
        this.targetTime = new Date().getTime() + 6430000
        this.targetTime1 = new Date().getTime() + 86430000
        this.targetTime2 = new Date().getTime() + 10000
    },
    onUnload() {
        this.clearTimer = true
    },
    methods: {
        myLinsterner() {
            this.status = '结束'
        }
    }
}
</script>

API

CountDown properties

属性

说明

类型

默认值

i-class

自定义 class 类名

String

-

target

目标时间

Number

-

show-day

是否显示天数

Boolean

false

format

时间格式化显示

String

-

clear-timer

是否停止计时

Boolean

false

CountDown events

事件名

说明

返回值

v-on:callback

倒计时结束回调

-

PreviousAvatar 头像NextDivider 分隔符

Last updated 5 years ago

Was this helpful?