icon-voice.vue 698 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <template>
  2. <view class="icon-voice">
  3. <text class="icon" :class="[`chat-${name}${index}`]"></text>
  4. </view>
  5. </template>
  6. <script>
  7. export default {
  8. props: {
  9. play: Boolean,
  10. name: String,
  11. },
  12. data() {
  13. return {
  14. timer: null,
  15. index: "",
  16. };
  17. },
  18. watch: {
  19. play(val) {
  20. clearInterval(this.timer);
  21. if (val) {
  22. this.index = 1;
  23. this.timer = setInterval(() => {
  24. if (this.index == 1) {
  25. this.index = "";
  26. } else {
  27. this.index += 1;
  28. }
  29. }, 500);
  30. } else {
  31. this.index = "";
  32. }
  33. },
  34. },
  35. };
  36. </script>
  37. <style lang="scss" scoped>
  38. .icon-voice {
  39. display: inline-block;
  40. .icon {
  41. font-size: 50rpx;
  42. position: relative;
  43. top: 4rpx;
  44. }
  45. }
  46. </style>