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

131
Visualizações
Bootstrap Vue Modal Component

I'm looking to make a global Bootstrap Vue Modal component that I can use for all of my modal needs.

The issue I am facing is that it keeps giving me an error regarding prop mutation. You cannot update them directly in the child component. Which makes sense.

This is what I have so far:

<template>
    <b-modal
        v-model="show"
        size="lg"
        scrollable
        centered
        header-class="event-close-modal-header"
        @hide="$emit('close')"
        @cancel="$emit('close')"
        @ok="$emit('close')"
        @show="handleShow"
    >
        <template #modal-title="{}">
            <span class="event-close-modal-header-mc2">{{ title }}</span>
        </template>

        <b-container fluid class="pb-4">
            <h1>Content goes here</h1>
            <slot />
        </b-container>
    </b-modal>
</template>

<script>
export default {
    props: {
        show: {
            type: Boolean,
            default: false,
            required: true,
        },
        title: {
            type: String,
            required: true,
        },
    },
    data() {
        return {};
    },
};
</script>

And in my parent I have something like this:

<ModalHelper
  :show.sync="modalOne" // modalOne is a data property
  title="One"
  @close="modalOne = false"
/>

<button @click="modalOne = true">Open Modal One</button>

Error: enter image description here

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

0

You can't use props in v-model. Try watch it, and copy new value into new variable in data:

data() {
   return {
      showModal: false
   }
},
watch: {
   show(newValue) {
     this.showModal = newValue;
   }
}

now use showModal in your code instead of "show".

However, this is no good approach. You should open-close bootstrap vue modals using:

$bvModal.show() $bvModal.hide()

Vue Bootstrap Modal

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