3
Good evening, I’m starting my studies in web development and I chose Vuejs with Vuetify to begin with. Right away I’m not getting a page change by clicking on a button. I installed the Vue-router by NPM and created the file router.js with the following code:
import Vue from 'vue'
import Router from 'vue-router'
import App from './App.vue'
import Dashboard from './Dashboard.vue'
Vue.use(Router)
export default new Router({
mode: 'history',
routes: [
{
path: '/',
name: 'App',
component: App
},
{
path: '/dashboard',
name: 'Dashboard',
component: Dashboard
}
]
})
Then I imported this file into main.js:
new Vue({router,vuetify,render: h => h(App)}).$mount('#app')
On the button I put the following code:
@click="$router.push('/dashboard')"
When you click the button, the URL address is changed correctly, but the page does not change to the Dashboard component. On the console, no error is shown. I searched but could not figure out the problem. Could anyone help me?
Have you tried:
<v-btn to="/dashboard">DASHBOARD</v-btn>
?– NoobSaibot
If none of the options work, try:
this.$router.replace('/dashboard')
– waghcwb