I would like to call function b from inside function a in a vue.js component
This is the code I have
methods:{
a(){
console.log("a")
b();
}
b(){
console.log("b")
}
}
you can do it by adding this before your function: this.yourFunction
export default{
data(){
return{
data1: 1,
data2: 1
}
},
methods:{
a(){
if(this.data1 == this.data2){
this.b(); //call b() function
}
},
b(){
//do something
},
}
}
you can also do the same to use your data() variables
if, I used data1 and data2Use this it will solve the problem.
methods:{
a(){
console.log("a")
this.b();
}
b(){
console.log("b")
}
}
If you want to call it outside the method use this.method()