Answer the question
In order to leave comments, you need to log in
Why doesn't the data in the object change after emit?
I had the value true in the array, so it remains, but according to my logic, it should change
Here is my example
ModalComponent.vue
<template>
...
<div v-else class="row">
<div class="col-sm-10">{{ field.label }}</div>
<div class="col-sm-2"><input type="checkbox" v-model="field.disabled" @click="actionColumns(field.name, field.disabled)"></div>
</div>
...
</template>
<script>
export default {
props: ['item'],
methods: {
actionColumns(name, result){
this.$emit('actionColumns', {name: name, disabled: result})
}
},
...
}
</script>
methods: {
...
actionColumns(result) { // result = {name: "full_name", disabled: false}
console.log(this.disabledColumnsData[result.name]); //ture
this.disabledColumnsData[result.name] = result.disabled;
console.log(this.disabledColumnsData[result.name]); //false
console.log(this.disabledColumnsData); // {full_name: true, ...}
}
...
}
Answer the question
In order to leave comments, you need to log in
Internal properties disabledColumnsData
are not reactive. You need to change them through
Vue.set(this.disabledColumnsData, result.name, result.disabled)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question