Will vuex store data too frequently so that the value will not change?

scene

I have a player component that passes events to another sibling page in the event of timeupdate , and I use vuex to pass data between them.

Code

// player.vue
<template>
  <div class="player">
  ...
    <audio  @timeupdate="updateTime" :src="`xxx.mp3`"></audio>
  </div>
</template>

import {mapMutations} from "vuex";
export default {
  name: "player",
  methods:{
    updateTime(e) {      
    //
    let currentTime=e.target.currentTime;
    this.setCurrentTime(currentTime)
    },
    ...mapMutations({
      setCurrentTime: "SET_CURRENT_TIME"      
    })
  }

}
// 
import {mapGetters} from "vuex";
<template>
  {{currentTime}}
</template>

export default{
  name:"xxx",
  computed:{
   ...mapGetters(["currentTime"])
  }

}
The currentTime on the

page has always been the initial value 0 in state . Is it cool if the setvalue is too fast?

Thanks in advance.

Apr.30,2021

No, it's usually a mistake.


have you found anything wrong, because I occasionally cause this problem when I use vuex to store the data returned by websocket? Lost data

Menu