0👍
newBlog
is declared inside the onSubmit
function, and it’s not accessible outside of that scope, leading to the error you observed.
To fix the issue, move the newBlog
declaration outside onSubmit
:
export default {
setup() {
//...
const newBlog = {...}
const onSubmit = (e) => {
this.$emit('add-blog', newBlog)
}
return { title, body, onSubmit, newBlog }
}
}
Source:stackexchange.com