Добавление новых данных работает хорошо для меня, но я хотел бы увидеть их немедленно. На данный момент я должен сделать обновление. Как я мог добиться такого эффекта? Я использую Laravel и Vue.
Это как-то связано с методом push, но я не знаю, что делать дальше
Вот мой код:
import JQuery from 'jquery'
let $ = JQuery
export default {
data() {
return {
word: { 'title': '', 'second_title': '', 'status': '' },
toggle: false,
words: []
}
},
created() {
axios.get('./api/word')
.then(response => this.words = response.data);
Event.$on('taskCreated', (title, second_title) => {
this.words.push(title);
this.words.push(second_title);
})
},
mounted() {
console.log('Component mounted.')
},
directives: {
focus: {
inserted: function (el) {
el.focus()
}
}
},
methods: {
editWord() {
$(".edit").toggle();
$(".inner").toggle();
},
doneEdit(id) {
var input = this.word;
console.log(input)
axios.patch('/api/word/' + id, input)
.then((response) => {
this.word = { 'title': '', 'second_title': '', 'id': '', 'status': '' };
console.log("Success edit");
})
},
}
}