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

234
Visualizações
how to use draggable in vuejs

i'm trying to use draggable to drag header column in table like this

<thead>
  <draggable
    v-model="fields"
    :element="'tr'"
    :options="{ animation: 150 }"
  >
    <th class="" style="min-width: 59px"><Checkbox /></th>
    <th
      v-for="(field, index) in fields"
      :key="index"
      :style="field.type === 'date' ? 'text-align:center' : ''"
    >
      {{ field.text }}
    </th>
  </draggable>
</thead>
<script>
  import Checkbox from "./Checkbox.vue";
  import draggable from "vuedraggable";
  export default {
    components: {
      Checkbox,
      draggable,
    },
    props: {
      fields: Array,
      data: Array,
    },

But when i launch project, it show error

Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "fields" Please help me Ths so much

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

0

The problem is that you defined your fields: Array and you are using it inside of your v-for there it is correct (if it's really an array).

But you have also used name fields inside of your dragable v-model. If you will rename this and change everything else inside of your code to the new name it should work out.

So in your case you send your data (fields) from your parent.vue to your child.vue and each time you select something from your dragable it will overwrite your array in the v-for.

So little example:
Array Fields: [Cat, Dog, Mouse] - You are selecting with v-model fields Cat - now your new Array Fields will be overwritten..

Hopefully it's now clear for you!

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