Why am I getting an error that says newBlog is not defined? I have defined it in the setup function and used it in the event handler function. What could be causing this issue?
<template>
<form @submit="onSubmit" class="add-form">
...
</form>
</template>
<script>
import { ref } from '@vue/reactivity'
export default {
setup() {
const title = ref('')
const body = ref('')
const onSubmit = (e) => {
e.preventDefault()
const newBlog = {
title: title,
body: body
}
this.$emit('add-blog', newBlog)
title.value = ''
title.body = ''
}
return { title, body, onSubmit, newBlog }
}
}
</script>