1
Well I have a little problem that when someone accesses http://www.meulink.com/route without having opened directly in the index (http://www.meulink.com/) and navigated by menu, the scripts contained in the route file, specifically within the function:
const router = new VueRouter({
mode: 'history',
routes: routes
})
router.afterEach((to, from) => {
meus scripts
});
Routes
import Vue from 'vue'
import VueRouter from 'vue-router'
import HomePage from '@/pages/Home'
import SecondPage from '@/pages/Secundaria'
import ThirdPage from '@/pages/Terciaria'
import FourthPage from '@/pages/Quartenaria'
Vue.use(VueRouter)
const routes = [
{
name: 'home',
path: '/',
component: HomePage
},
{
name: 'Secundaria',
path: '/secundaria',
component: SecondPage,
props: true
},
{
name: 'Terciaria',
path: '/terciaria',
component: ThirdPage,
props: true
},
{
name: 'Quartenaria',
path: '/quartenaria',
component: FourthPage,
props: true
}
]
const router = new VueRouter({
mode: 'history',
routes: routes
})
router.afterEach((to, from) => {
var globalNav = $('[data-globalnav]'),
// Link dentro do menu global cujo href é igual à rota de destino
link = globalNav.find(`a[href="${to.path}"]`);
// Define como item atual o 'li' que contém o link encontrado
globalNav.meGlobalnav().setCurrent(link.parent());
})
export default router
do not perform. How do I get around this?
You can show your array
routes
?– Sergio
I added to the post
– Douglas Teles