Countdown
安装
局部注册
全局注册
import { Countdown } from 'vux'
export default {
components: {
Countdown
}
}
// 在入口文件全局引入
import Vue from 'vue'
import { Countdown } from 'vux'
Vue.component('countdown', Countdown)
自动倒计时
<template>
<div>
<group :title=" $t('Automatic countdown') ">
<cell title="15s" v-model="value">
<countdown v-model="time" @on-finish="finish" v-show="show"></countdown>
</cell>
</group>
</div>
</template>
<script>
import { Countdown, Group, Cell } from 'vux'
export default {
components: {
Countdown,
Cell,
Group
},
data () {
return {
show: true,
time: 15,
value: ''
}
},
methods: {
finish (index) {
this.show = false
this.value = 'completed'
console.log('current index', index)
}
}
}
</script>
Show code
手动模式
<template>
<div>
<group :title=" $t('Manually') ">
<x-switch :title=" $t('Start') " v-model="start"></x-switch>
<cell title="15s">
<countdown v-model="time" :start="start" @on-finish="finish"></countdown>
</cell>
</group>
</div>
</template>
<script>
import { Countdown, Group, Cell, XSwitch } from 'vux'
export default {
components: {
Countdown,
Cell,
Group,
XSwitch
},
data () {
return {
time: 15,
value: '',
start: false
}
},
methods: {
finish (index) {
this.start = false
this.time = 20
}
}
}
</script>
Show code
属性
名字 | 类型 | 默认值 | 说明 | 版本要求 |
value | number | 时间,秒为单位 | — | |
start | boolean | true | 是否开始计数 | — |
贡献者
该组件(包含文档)迭代次数 5,贡献人数 1
airyland
发布日志
- v2.0.0 [deprecated] 下一版本开始不再维护