forDigitalFlop.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <div class="for-digital-flop">
  3. <dv-digital-flop :config="currentConfig" style="width:200px;height:50px;" />
  4. <div class="button" @click="change">切换数据</div>
  5. </div>
  6. </template>
  7. <script>
  8. export default {
  9. name: 'ForDigitalFlop',
  10. props: ['data'],
  11. data () {
  12. return {
  13. index: 0,
  14. currentConfig: {}
  15. }
  16. },
  17. methods: {
  18. change () {
  19. let { index, data } = this
  20. index += 1
  21. if (index >= data.length) index = 0
  22. this.currentConfig = data[index]
  23. this.index = index
  24. }
  25. },
  26. mounted () {
  27. const { data } = this
  28. this.currentConfig = data[0]
  29. }
  30. }
  31. </script>
  32. <style lang="less">
  33. .for-digital-flop {
  34. position: relative;
  35. width: 100%;
  36. height: 100%;
  37. display: flex;
  38. justify-content: center;
  39. align-items: center;
  40. &:hover .button {
  41. visibility: visible;
  42. }
  43. .button {
  44. position: absolute;
  45. right: 0px;
  46. bottom: 0px;
  47. background-color: #37a2da;
  48. color: #fff;
  49. padding: 3px 20px;
  50. font-size: 15px;
  51. font-weight: normal;
  52. cursor: pointer;
  53. visibility: hidden;
  54. &:active {
  55. color: #37a2da;
  56. }
  57. }
  58. }
  59. </style>