[Vuejs]-Computed variable is undefined after button click

0👍

You used currentTrack.duration instead of player.currentTrack.duration, try this:

<div class="player__timer">
  <div class="player__timer__elapsed" v-text="player.elapsed"></div>

  <div class="player__timer__total" v-text="player.currentTrack.duration"></div>
</div>

<div class="slider player__progress-bar">  
  <input type="range" :value="player.elapsed" :max="player.currentTrack.duration" />
</div>

0👍

this is the correct way to do object.assign. My method above is wrong.

let player = {
  currentTrack: 0,
  other: ""
};

console.log(player);

player = Object.assign(
  {},
  player,
  { currentTrack: 2}
);

console.log(player);

Leave a comment