Vue-router: PascalCase support for Link component

Created on 21 Aug 2018  路  6Comments  路  Source: vuejs/vue-router

What problem does this feature solve?

Would like to be able to use <RouterLink> instead of <router-link>.

Reason for this is that in the Vue Style Guide PascalCase is recommended and in the latest version of [email protected] this rule is now auto-fixable (e.g. it will convert <router-link> into <RouterLink>) but this breaks and the link does not work. https://vuejs.org/v2/style-guide/#Component-name-casing-in-templates-strongly-recommended

We have gotten around the issue by re-defining the router components like so:

const RouterView = Vue.component('router-view');
const RouterLink = Vue.component('router-link');
Vue.component('RouterView', RouterView);
Vue.component('RouterLink', RouterLink);

What does the proposed API look like?

Update component definition in vue-router to have both PascalCase and kebab-case:

Vue.component('router-view', View);
Vue.component('RouterView', View);
Vue.component('router-link', Link);
Vue.component('RouterLink', Link);

Most helpful comment

This is done but not released yet :)

All 6 comments

This is done but not released yet :)

Okay great, thanks for the update @posva. Do you know when this will be released or a link to a PR so I can follow along?

watch the repo for releases

Wow there hasn't been a release in like 10 months, is there anything I can do to help speed up the process?

For anyone else that finds this, it looks like this commit from Oct 24 in 2017 (10 months ago) is the one https://github.com/vuejs/vue-router/commit/f9585651dbcede28a3a48c47abad3200f655d776.

@posva the changes you have made seem to be in now, however the main file (from package.json) is still outputting the kebab-case version as the component name. I think this is why you still cannot use PascalCase :( - https://github.com/vuejs/vue-router/blob/dev/dist/vue-router.common.js

@posva just cloned the repo locally and ran npm run build and got the expected outcome in the vue-router.common.js

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yyx990803 picture yyx990803  路  3Comments

rr326 picture rr326  路  3Comments

baijunjie picture baijunjie  路  3Comments

shinygang picture shinygang  路  3Comments

mitar picture mitar  路  3Comments