Blame view
src/views/components-demo/count-to.vue
4.97 KB
d7d9c38c2 auto commit the c... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
<template> <div class="components-container"> <aside> <a href="https://github.com/PanJiaChen/vue-countTo" target="_blank">countTo-component</a> </aside> <count-to ref="example" :start-val="_startVal" :end-val="_endVal" :duration="_duration" :decimals="_decimals" :separator="_separator" :prefix="_prefix" :suffix="_suffix" :autoplay="false" class="example" /> <div style="margin-left: 25%;margin-top: 40px;"> <label class="label" for="startValInput">startVal: <input v-model.number="setStartVal" type="number" name="startValInput"> </label> <label class="label" for="endValInput">endVal: <input v-model.number="setEndVal" type="number" name="endVaInput"> </label> <label class="label" for="durationInput">duration: <input v-model.number="setDuration" type="number" name="durationInput"> </label> <div class="startBtn example-btn" @click="start"> Start </div> <div class="pause-resume-btn example-btn" @click="pauseResume"> pause/resume </div> <br> <label class="label" for="decimalsInput">decimals: <input v-model.number="setDecimals" type="number" name="decimalsInput"> </label> <label class="label" for="separatorInput">separator: <input v-model="setSeparator" name="separatorInput"> </label> <label class="label" for="prefixInput">prefix: <input v-model="setPrefix" name="prefixInput"> </label> <label class="label" for="suffixInput">suffix: <input v-model="setSuffix" name="suffixInput"> </label> </div> <aside><count-to :start-val='{{ _startVal }}' :end-val='{{ _endVal }}' :duration='{{ _duration }}' :decimals='{{ _decimals }}' :separator='{{ _separator }}' :prefix='{{ _prefix }}' :suffix='{{ _suffix }}' :autoplay=false></aside> </div> </template> <script> import countTo from 'vue-count-to' export default { name: 'CountToDemo', components: { countTo }, data() { return { setStartVal: 0, setEndVal: 2017, setDuration: 4000, setDecimals: 0, setSeparator: ',', setSuffix: ' rmb', setPrefix: '¥ ' } }, computed: { _startVal() { if (this.setStartVal) { return this.setStartVal } else { return 0 } }, _endVal() { if (this.setEndVal) { return this.setEndVal } else { return 0 } }, _duration() { if (this.setDuration) { return this.setDuration } else { return 100 } }, _decimals() { if (this.setDecimals) { if (this.setDecimals < 0 || this.setDecimals > 20) { alert('digits argument must be between 0 and 20') return 0 } return this.setDecimals } else { return 0 } }, _separator() { return this.setSeparator }, _suffix() { return this.setSuffix }, _prefix() { return this.setPrefix } }, methods: { start() { this.$refs.example.start() }, pauseResume() { this.$refs.example.pauseResume() } } } </script> <style scoped> .example-btn { display: inline-block; margin-bottom: 0; font-weight: 500; text-align: center; -ms-touch-action: manipulation; touch-action: manipulation; cursor: pointer; background-image: none; border: 1px solid transparent; white-space: nowrap; line-height: 1.5; padding: 4px 15px; font-size: 12px; border-radius: 4px; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; -webkit-transition: all .3s cubic-bezier(.645, .045, .355, 1); transition: all .3s cubic-bezier(.645, .045, .355, 1); position: relative; color: rgba(0, 0, 0, .65); background-color: #fff; border-color: #d9d9d9; } .example-btn:hover { color: #4AB7BD; background-color: #fff; border-color: #4AB7BD; } .example { font-size: 50px; color: #F6416C; display: block; margin: 10px 0; text-align: center; font-size: 80px; font-weight: 500; } .label { color: #2f4f4f; font-size: 16px; display: inline-block; margin: 15px 30px 15px 0; } input { position: relative; display: inline-block; padding: 4px 7px; width: 70px; height: 28px; cursor: text; font-size: 12px; line-height: 1.5; color: rgba(0, 0, 0, .65); background-color: #fff; background-image: none; border: 1px solid #d9d9d9; border-radius: 4px; -webkit-transition: all .3s; transition: all .3s; } .startBtn { margin-left: 20px; font-size: 20px; color: #30B08F; background-color: #fff; } .startBtn:hover { background-color: #30B08F; color: #fff; border-color: #30B08F; } .pause-resume-btn { font-size: 20px; color: #E65D6E; background-color: #fff; } .pause-resume-btn:hover { background-color: #E65D6E; color: #fff; border-color: #E65D6E; } </style> |