I'm trying to figure out how to access a method or variable that is defined in the Vuex 4 store within my Blade file. Currently, I am utilizing a compiled app.js from Vite. While I can easily access the store in Vue.js components, I am curious if it's possible to do so in a Blade file as well. Of course, the Vue.js #app instance must be present.
If I add the following code snippet at the end of my Blade file:
<script>
import {useStore} from "vuex";
import {onMounted, watch, ref, defineComponent} from 'vue'
export default {
setup() {
const click = () => {
store.commit('mutation');
};
onMounted(() => {
alert('test');
});
const store = useStore();
return {
store,
click
};
},
}
</script>
The console throws an error similar to this:
Unexpected token '{'. Import call expects exactly one argument.