SecondPage.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <b-card title="YuGiOh">
  3. <b-card-text>YuGiOh LP模擬</b-card-text>
  4. <div>
  5. <B-Button @click="countDown()" variant="info">歸零</B-Button>
  6. <B-Button @click="reset()" variant="primary">重置</B-Button>
  7. <div class="container">
  8. <img src="/LP.png" style="width:200px;">
  9. <div class="centered">{{ animatedNumber }}</div>
  10. </div>
  11. </div>
  12. </b-card>
  13. </template>
  14. <script>
  15. import { BCard, BCardText,BButton } from 'bootstrap-vue'
  16. // const sound = require("@/assets/hp.mp3");
  17. export default {
  18. components: {
  19. BCard,
  20. BCardText,
  21. BButton,
  22. },
  23. data() {
  24. return {
  25. tweenedNumber: 5800,
  26. number: 5800,
  27. }
  28. },
  29. computed: {
  30. animatedNumber: function () {
  31. return this.tweenedNumber.toFixed(0);
  32. }
  33. },
  34. methods:{
  35. countDown(){
  36. this.number = 0;
  37. },
  38. reset(){
  39. this.number = 5800;
  40. }
  41. },
  42. watch: {
  43. number: function (newValue) {
  44. const path = "/hp.mp3";
  45. const audio = new Audio(path);
  46. var playPromise = audio.play();
  47. if (playPromise !== undefined) {
  48. playPromise.then(_ => {
  49. gsap.to(this.$data, { duration: 1.6, tweenedNumber: newValue });
  50. })
  51. .catch(error => {
  52. console.log(`playSound error: ${error}`);
  53. });
  54. }
  55. }
  56. }
  57. }
  58. </script>
  59. <style>
  60. .container {
  61. position: relative;
  62. text-align: center;
  63. font-size: 48px;
  64. font-family: serif;
  65. font-style: italic;
  66. }
  67. .centered {
  68. position: absolute;
  69. top: 65%;
  70. left: 50%;
  71. transform: translate(-50%, -50%);
  72. background: linear-gradient(to bottom, #E5DDDB, #9A8B76, #7F723E);
  73. background-clip: text;
  74. -webkit-background-clip: text;
  75. text-stroke: 1px #3A3230;
  76. -webkit-text-stroke: 1px #3A3230;
  77. text-align: right;
  78. color: transparent;
  79. width:100px;
  80. }
  81. </style>