Skip to content

Commit

Permalink
feat: 初始化倒计时组件
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzhenfei committed Sep 28, 2020
1 parent 6b4e9ad commit 6a140a5
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
59 changes: 59 additions & 0 deletions components/pi-count-down/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<template>
<view
class="pi-width-100P"
:style="[customStyle, { height: `${statusBarHeight}px`, background: background }]"
:class="[customClass]"
/>
</template>

<script>
import ValueSync from '../../mixin/value-sync'
import { getConfig } from '../../config'
const { countDwon } = getConfig()
const TAG = 'PiCountDown'
export default {
name: TAG,
// 混入v-model
mixins: [ValueSync],
props: {
// 初始值,接收一个时间戳
value: {
required: false
},
// 自定义样式,对象形式(默认值:{})
customStyle: {
type: Object,
default() {
return countDwon.customStyle
}
},
// 自定义样式类,字符串形式('')
customClass: {
type: String,
default() {
return countDwon.customClass
}
},
autoplay: {
type: Boolean,
default() {
return countDwon.autoplay
}
}
},
watch: {
value: {
deep: true,
immediate: true,
handler(value) {
this.autoplay && this.run()
}
}
},
methods: {
run() {}
}
}
</script>
5 changes: 5 additions & 0 deletions config/countDown.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
customClass: '', // 自定义样式类,字符串形式('')
customStyle: {}, // 自定义样式,对象形式(默认值:{})
autoplay: true // 是否自动开始倒计时,如果为false,需手动调用开始方法
}

0 comments on commit 6a140a5

Please sign in to comment.