How can we call Vue Methods and use Vue Variables in JavaScript?
Below Example, calling test() or get value of any variable
I am rendering my page using InertiaJS.
<script>
import Layout from '@/Shared/Layout'
export default {
metaInfo: { title: 'Create User' },
layout: Layout,
props: {
errors: Object,
},
remember: 'form',
data() {
return {
sending: false,
form: {
first_name: null,
last_name: null,
email: null,
password: null,
owner: false,
photo: null,
},
}
},
methods: {
test() {
//do something here
console.log('test');
},
},
}
// Calling this should call Vue Method. But It's not working
test();
</script>