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

190
Visualizações
Issue declaring let in a function

I'm attempting to clear a setTimer() every time a key is pressed in my text input box, as my text input keeps sending update requests mid-typing, causing problems. However the code I have to tackle this issue is not working, due to the placement of my 'let', however I've put it everywhere I can think of, or changed to 'Var' and still not functioning. I'd appreciate on input on how I can retool this to achieve my desired result.

JS:

      computed: {
    ...mapGetters(['allDocumentTypeGroups', 'currentTicketCaseFiles', 'activeAttachmentIndex', 'showAttachmentsPreview', 'activeAttachments']),

    attachmentAcceptedLabel() {
      return this.attachmentAccepted ? this.t('accepted') : this.t('ignored');
    },
    attachmentAccepted: {
      get: function () {
        return !this.attachment.ignoreAttachment;
      },
      set: function (val) {
        return this.updateAttachment([this.attachment.id, { ignoreAttachment: !val }]);
      },
    },
    documentType: {
      get: function() {
        return this.attachment.documentTypeId;
      },
      set: function(val) {
        return this.updateAttachment([this.attachment.id, { documentTypeId: val }]);
      },
    },
    approveAttachment: {
      get: function() {
        return this.attachment.approvedAttachment;
      },
      set: function(val) {
        return this.updateAttachment([this.attachment.id, { approvedAttachment: val }]);
      },
    },
    strValue: {
      let timer;
      get: function () {
        return this.attachment.strValue;
      },
      set: function (val) {
        if(timer){
          clearTimeout(timer);
        }
        let self = this;
        timer = setTimeout(function(){ return self.updateAttachment([self.attachment.id, { strValue: val }]) },8000);
      },
    },
  },
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can't put variables in an object literal, use a property.

    strValue: {
      timer: null,
      get: function () {
        return this.attachment.strValue;
      },
      set: function (val) {
        if(this.timer){
          clearTimeout(this.timer);
        }
        let self = this;
        this.timer = setTimeout(function(){ return self.updateAttachment([self.attachment.id, { strValue: val }]) },8000);
      },
    },
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