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

201
Visualizações
how to add a string to another string in Vue.js

I am working on a Vue project. I tried to add a character to a prop using this code:

mounted() {
  this.link = this.link + '/';
}

the problem is that I getting this error on the console:

Uncaught TypeError: 'set' on proxy: trap returned falsish for property 'link'

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You shouldn't mutate props, one way to do this is to create a computed property:

computed: {
  formattedLink: function() {
    return this.link + '/';
  }
}
about 4 years ago · Juan Pablo Isaza Relatório

0

From the Vue docs:

All props form a one-way-down binding between the child property and the parent one: when the parent property updates, it will flow down to the child, but not the other way around. This prevents child components from accidentally mutating the parent's state, which can make your app's data flow harder to understand.

You can emit the data from the child component and then listen for it in the parent component for any changes to keep the data in sync.

<child-component :link="value" @updatedLink="link = $event"></child-component>

From the child just emit the updated value.

 mounted() {
  const val = this.link + '/';
  this.$emit('updatedLink', val)
}

You can read more about it here: https://v3.vuejs.org/guide/component-custom-events.html

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