Answer the question
In order to leave comments, you need to log in
How to call a method inside a component?
How to use the testFunction method inside the test-26. v-on:click="testFunction"
The problem is that inside the test-26.vue file it does not see v-on:click="testFunction", which is written in app.js
inside test-26.vue, something like this
<template>
<button @click="testFunction">текст</button>
</template>
Vue.component('test-n', require('./components/tests/test-n.vue'));
Vue.component('test-26', require('./components/tests/test-26.vue'));
Vue.http.headers.common['X-CSRF-TOKEN'] = window.Laravel.csrfToken;
let topicInfo = {
template_id: '',
timer: '',
type: '',
tasks: '',
solutions: '',
};
const app = new Vue({
el: '#app',
data: {
currentView: 'test-1',
step: 1,
topicInfo,
name: 'Vue.js'
},
methods: {
prev() {
this.step--;
},
next() {
this.step++;
},
mounted() {
console.log('Component test-1.');
},
onSubmitForm() {
let info = this.topicInfo;
this.$http.post('/backend/topics', info).then((response) => {
console.log('request completed');
}).catch((e) => {
console.log(e);
});
},
testFunction: function (event) {
console.log('test clicked')
},
},
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question