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

228
Visualizações
"Write operation failed: computed property "posts" is readonly"

I try remove post from PostList, but getting an error

<PostList
    :posts="sortedAndSearchedPosts"
    @remove="removePost"
    v-if="!isPostsLoading"
  />

remove post function

 removePost(post) {
      this.posts = this.posts.filter((p) => p.id !== post.id);
    },

posts initialized here

 computed: {
    ...mapState({
      posts: (state) => state.post.posts,
    }),
    ...mapGetters({
      sortedPosts: "post/sortedPosts",
      sortedAndSearchedPosts: "post/sortedAndSearchedPosts",
    }),
  },
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Not clear where this.posts are actually initially set up. If I guess your architecture right, I see 2 options for you:

  • either directly remove the post in your store so that sortedAndSearchedPosts reflects the change directly
  • if you don't want to update the global state, build a local copy when you initialise posts:
data () {
   return {
      posts: [...this.sortedAndSearchedPosts],
      ...
   }
},

and update your code to use the local list of posts:

<PostList
    :posts="posts"
    ...
  />

Hope this helps!

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