Ich versuche, in einem Tutor-Profil in einer benutzerdefinierten Komponente mit Laravel Spark zu laden. Es aktualisiert mit was auch immer ich kein Problem, aber das ist immer leer, wenn geladen.Aktualisieren der benutzerdefinierten Komponente Formular nach Erhalt einer Antwort
Das Bauteil selbst ist wie folgt:
Vue.component('tutor-settings', {
data() {
return {
tutor: [],
updateTutorProfileForm: new SparkForm({
profile: ''
})
};
},
created() {
this.getTutor();
Bus.$on('updateTutor', function() {
this.updateTutorProfileForm.profile = this.tutor.profile;
});
},
mounted() {
this.updateTutorProfileForm.profile = this.tutor.profile;
},
methods: {
getTutor() {
this.$http.get('/tutor/current')
.then(response => {
Bus.$emit('updateTutor');
this.tutor = response.data;
});
},
updateTutorProfile() {
Spark.put('/tutor/update/profile', this.updateTutorProfileForm)
.then(() => {
// show sweet alert
swal({
type: 'success',
title: 'Success!',
text: 'Your tutor profile has been updated!',
timer: 2500,
showConfirmButton: false
});
});
},
}
});
Hier ist die Inline-Vorlage habe ich:
<tutor-settings inline-template>
<div class="panel panel-default">
<div class="panel-heading">Tutor Profile</div>
<form class="form-horizontal" role="form">
<div class="panel-body">
<div class="form-group" :class="{'has-error': updateTutorProfileForm.errors.has('profile')}">
<div class="col-md-12">
<textarea class="form-control" rows="7" v-model="updateTutorProfileForm.profile" style="font-family: monospace;"></textarea>
<span class="help-block" v-show="updateTutorProfileForm.errors.has('profile')">
@{{ updateTutorProfileForm.errors.get('profile') }}
</span>
</div>
</div>
</div>
<div class="panel-footer">
<!-- Update Button -->
<button type="submit" class="btn btn-primary"
@click.prevent="updateTutorProfile"
:disabled="updateTutorProfileForm.busy">
Update
</button>
</div>
</form>
</div>
Sehr neu zu Vue und unterwegs zu lernen versuchen! Jede Hilfe wird sehr geschätzt!
können Sie besser erklären? Es ist schwer zu verstehen, was ist dein Problem –
@MU Bitte beachten Sie meinen Kommentar zu der Antwort unten, es sieht nicht aus wie die '$ emit 'ruft die' $ on' Methode – davidsneal