Answer the question
In order to leave comments, you need to log in
Why is vue js props data not updating?
The data is received by ajax request when the button is clicked.
//Button
<button id="show-modal"
class="P2CL3TInfo"
v-bind:name="selecId = item.id"
@click="open()">
</button>
<modal v-if="showModal" @close="showModal = false"
:country="mod[0].country"
:city="mod[0].city"
:dt="mod[0].created" >
</modal>
//Компонент
Vue.component('modal', {
props: ['country', 'city', 'vendor', 'dt'],
data: function () {
return {
}
},
delimiters: ['${', '}'],
template: '#modal-template',
//Ajax запрос
open: function(){
axios.get("{% url 'url' %}",{
headers: {
'X-Requested-With': 'XMLHttpRequest'
},
params: {
id: this.selecId
}}).then((response) => {
this.$data.mod = response.data
this.showModal = true
}).catch(function (error) {
this.selected = error;
});
},
Answer the question
In order to leave comments, you need to log in
Because this does not pass into the axios object, initialize the variable to be a reference to this.
this.$data.mod = response.data
- so it is not necessary
About set and $set
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question