character.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <view class="character-parent">
  3. <view class="character-container">
  4. <view class="character" :class="deley?'play':''" :style="{backgroundImage:`url(${imageSrc})`}"></view>
  5. </view>
  6. <!-- <button @tap="onplay()">play</button> -->
  7. </view>
  8. </template>
  9. <script>
  10. import imageSrc from "@/static/character/character.png"
  11. export default {
  12. props: {
  13. parentLeft: {
  14. type: Number,
  15. default: 0
  16. },
  17. electLeft: {
  18. type: Number,
  19. default: 150
  20. },
  21. backgroundColor: {
  22. type: String,
  23. default: '#007AFF'
  24. },
  25. borderColor: {
  26. type: String,
  27. default: '#000000'
  28. },
  29. color: {
  30. type: String,
  31. default: '#000000'
  32. },
  33. duration:{
  34. type: Number,
  35. default: 3000
  36. }
  37. },
  38. data() {
  39. return {
  40. // 心电图实列数组
  41. elects: [],
  42. bRun:false,
  43. deley:true,
  44. imageSrc:imageSrc
  45. };
  46. },
  47. created() {
  48. // setTimeout(()=>{
  49. // this.deley = true;
  50. // console.log("character created");
  51. // },5000)
  52. },
  53. methods: {
  54. onplay(){
  55. this.deley = true;
  56. console.log("character created");
  57. }
  58. }
  59. }
  60. </script>
  61. <style lang="scss">
  62. .character-parent {
  63. // border: 1rpx solid #ffaa7f;
  64. position: relative;
  65. display: flex;
  66. justify-content: center;
  67. }
  68. .character-container {
  69. width: 125px;
  70. // height: 830px;
  71. // border: 1rpx solid #000000;
  72. position: relative;
  73. overflow: hidden;
  74. }
  75. .character {
  76. background-repeat: no-repeat;
  77. width: 125px;
  78. height: 138px;
  79. position: relative;
  80. // background-color: #007AFF;
  81. }
  82. .play{
  83. animation: character-run 1s steps(1, start) infinite;
  84. animation-play-state: running;
  85. }
  86. @keyframes character-run {
  87. 0%,100% {
  88. background-position: 0 0;
  89. }
  90. @for $i from 1 through 34 {
  91. #{$i*3.03}% {
  92. background-position: 0 -138px*$i;
  93. }
  94. }
  95. }
  96. </style>