Answer the question
In order to leave comments, you need to log in
How to create a new object in VueJS?
Vue.component('list_appointments', {
delimiters: ['{>', '<}'],
template: '#list_appointments-template',
data: function () {
return {
active_list_appointments_template: false,
drug: {
id: null,
patient: null,
disease_history: null,
drug: null,
start_day: null,
end_day: null,
is_delete: false,
},
list_appointments_drugs: [],
}
},
methods: {
addDrug: function () {
// хочу добавить в list_appointments_drugs новый объект drug, но получается что добавляю модель
this.list_appointments_drugs.unshift(this.drug)
},
editDrug: function () {
},
deleteDrug: function () {
},
openTemplate: function () {
this.active_list_appointments_template = true
},
closeTemplate: function () {
this.active_list_appointments_template = false
},
onCancel: function () {
this.close()
},
onConfirm: function () {
this.close()
}
},
beforeCreate: function () {
var self = this
//Профиль пациента
axios.get('http://' + window.location.host + '/api/patients/' + document.getElementById('id_patient').innerText + '/?format=json').then(function (response) {
self.patient = response.data
}).catch(function (error) {
console.log(error);
});
//Текущая история болезни
axios.get('http://' + window.location.host + '/api/disease_stories/' + document.getElementById('id_disease_history').innerText + '/?format=json').then(function (response) {
self.disease_history = response.data
}).catch(function (error) {
console.log(error);
});
}
})
Answer the question
In order to leave comments, you need to log in
// хочу добавить в list_appointments_drugs новый объект drug, но получается что добавляю модель
this.list_appointments_drugs.unshift(this.drug)
this.list_appointments_drugs.unshift({ ...this.drug })
data: () => ({
drug: null,
defaultDrugData: {
...
},
...
}),
created() {
this.resetDrug();
},
methods: {
addDrug() {
this.list_appointments_drugs.unshift(this.drug);
this.resetDrug();
},
resetDrug() {
this.drug = { ...this.defaultDrugData };
},
...
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question