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.