Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

368
Visualizações
Trying to get my clock to work in bootstrapvue - what am I doing wrong?

Hey guys these are my codes trying to get my clock to work in bootstrap vue. I want the time to show real time with the seconds moving. Dates work, and time works, but time is stationary. What am i doing wrong? Newbie..#thanks

    <template>
<div>
<div>
{{timestring}} 
</div>
<div>
{{timeclock}} 
</div>
</div>
</template>


<script>
data ()=> ({
timeString: '',
timeclock: '',
stopClock: false}),

    mounted () {
    this.nowTime();
    this.nowclock();
  },
  methods: {
    nowTime () {
      this.timeString = new Date(Date.now()).toLocaleDateString('en-US',
        { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' });
      if (!this.stopClock) {
        setTimeout(this.nowTime, 285);
      }
    },
    nowclock () {
      this.timeclock = +' ' + new Date(Date.now()).toLocaleTimeString('en-US');
      if (!this.stopClock) {
        setTimeout(this.nowTime, 285);
      }
    }
  },
  beforeDestroy () {
    this.stopClock = true;
  }
};
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can just use setTimeout with 1000ms time interval with this.nowclock call back function

Codesandbox Demo

nowclock() {
  this.timeclock = +" " + new Date(Date.now()).toLocaleTimeString("en-US");
  if (!this.stopClock) setTimeout(this.nowclock, 1000);
},
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda