export default { components: { PlayerHeader, PlayerMiddle, PlayerBottom }, name: "Player", data() { return { totalTime: 0, curTime: 0, }; }, created() {}, mounted() { this.$refs.audio.oncanplay = () => { // console.log("11111===", this.$refs.audio.duration); this.totalTime = this.$refs.audio.duration; }; }, methods: { timeupdate(e) { // console.log("time===", e.target.currentTime); this.curTime = e.target.currentTime; }, }, computed: { // mapGetters辅助函数 ...mapGetters([ "isFullScreen", "currentSong", "isPlaying", "currentTime", "currentLyric", ]), }, watch: { currentSong(newV) {}, isPlaying(newV) { if (newV) { // this.$refs.audio.oncanplay = () => { this.$refs.audio.play(); // }; } else { this.$refs.audio.pause(); } }, currentTime(newV) { this.$refs.audio.currentTime = newV; }, }, };
|