代码如下
let routes = [
{
path: '/goods', component: goods
},
{
path: '/ratings', component: ratings
},
{
path: '/sellers', component: sellers
}
]
const router = new VueRouter({
routes,
linkActiveClass: 'active'
})
new Vue({
router,
render: h => h(App)
}).$mount('#app')
router.go('/goods')
vue 1.0版本版本使用router.go('/goods'),但是在2.0中是用router.push(‘/goods’),变成了这个router.push ,据说是为了和history api 保持一致