I'm using ionic with vue to develop an app. I made a custom button and want to include in another component. I'm trying to assign a function to the button but doesnt seem to work. The error i got is this:
[Vue warn]: Invalid prop: type check failed for prop "onClick". Expected Function, got String with value "addTodo".
First time using vue.Thanks in advance.
Button component
<template>
<ion-footer>
<ion-button fill="outline" expand="block" color="primary" @click="onClick">
<ion-ripple-effect></ion-ripple-effect>
{{text}}
</ion-button>
</ion-footer>
</template>
<script>
export default {
props: {
onClick:Function,
text:String,
}
}
</script>
Another Component
<template>
<ion-row>
<ion-col>
<main-btn text="Add Activity" onClick="addTodo"></main-btn>
</ion-col>
</ion-row>
</ion-grid>
</template>
<script>
import axios from 'axios';
export default {
data() {
return {
todos: []
}
},
methods: {
addTodo() {
this.$router.push({path: '/todos/add'})
}
},
created() {
axios.get('http://localhost:3001/todos')
.then(res => this.todos = res.data)
}
}
</script>
onClick="addTodo()"or:onClick="addTodo()"?:onClick="addTodo"?