0π
At the point that you are calling this.$router
, it is undefined
Make sure you have made the router globally available in your Vue app.
Make sure that this component can "see" your router. The easiest way to check is to add a mounted
hook to the JoinRoom
component:
mounted() {
console.log({router: this.$router});
}
Report back what that displays.
I am assuming the JS code you showed is from JoinRoom.vue
Please confirm that it is inside the methods
of the export default
section of the JS code. Outside that, this
will not mean what you want it to mean.
Your error message refers to JoinRoom.vue
.
But you have shown us ChatRoom.vue
.
- [Vuejs]-Why the error runs β Uncaught SyntaxError: The requested module '/src/router/index.js' does not provide an export named 'default' at main.js vue?
- [Vuejs]-How to get a reference to the current pinia store from a (composable) action?
Source:stackexchange.com