fix: Vue.component(RouterLink) is undefined in vue-router 3.0.0 (#4668)

This commit is contained in:
Xin Du (Clark) 2019-01-02 12:06:47 +00:00 committed by Sébastien Chopin
parent b210724e60
commit 7ff4058318

View File

@ -81,6 +81,12 @@ const _routes = recursiveRoutes(router.routes, ' ', _components, 2)
}).join('\n')%>
Vue.use(Router)
// router-view was changed to RouterView in vue-router 3.0.2
// Fix: Vue.component('RouterLink') is undefined in vue-router 3.0.0
if (!Vue.component('RouterLink')) {
Vue.options.components['RouterView'] = Vue.component('router-view')
Vue.options.components['RouterLink'] = Vue.component('router-link')
}
<% if (router.scrollBehavior) { %>
const scrollBehavior = <%= serializeFunction(router.scrollBehavior) %>