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

126
Visualizações
Cannot read properties of undefined (reading '$set') vuejs

So i'm trying to reorder the Documents array when a document gets deleted. My document array looks something like this:

[
    {
        "id": 1,
        "name": "document1"
        "document_number": 1,
    },
    {
        "id": 30,
        "name": "document2"
        "document_number": 2,
    },
    {
        "id": 4,
        "name": "document3"
        "document_number": 3,
    },
    {
        "id": 4,
        "name": "document4"
        "document_number": 4,
    }
]

now if user deletes "document2" I want to reactively change "document_number" for document3,document4 to "2","3".

What I am trying:

reorderDocuments(document_number){
            //filtering all documents that have "document_number" higher then the deleted document
            const filteredDocuments = this.Documents.filter(function (e) {
                return e.document_number > document_number;
            });
            //the filtering works as intended so now I use a for loop to loop thru all those documents
            for(var i = 0; i < filteredDocuments.length; i++){
                //here i am getting index of the document that i want to change
                this.index = this.Documents.findIndex(x => x.id === filteredDocuments[i].id);
                //the new number that should take place for document_number
                const newNumber = filteredDocuments[i].document_number - 1;

                //then im using $set to set that new number for the document
                //here is where i get an error
                this.Documents.document_number.$set(this.index, newNumber);
            }
        },

whats wrong?

error:

TypeError: Cannot read properties of undefined (reading '$set')
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

vm.$set or this.$set instance method, which is an alias to the global Vue.set. Generally we use it set vuex states. Therefore I recommend you to use

this.Documents[this.index]. document_number = newNumber;
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