Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hounour routes of a plugin in main or parent component app #3222

Closed
bitquality opened this issue Jun 6, 2020 · 1 comment
Closed

hounour routes of a plugin in main or parent component app #3222

bitquality opened this issue Jun 6, 2020 · 1 comment

Comments

@bitquality
Copy link

bitquality commented Jun 6, 2020

Version

3.3.2

Reproduction link

https://new-issue.vuejs.org/?repo=vuejs/vue-router

Steps to reproduce

I have developed a plugin and i am able to load it in my main app. And install method looks like below and following is its routes.

my plugin has one main component i am exporting as pplugin:

<template>

<div id="profile">
  <p>
    <router-link to="/profileinfo/updateEmail">updateEmail</router-link>
    <router-link to="/profileinfo/updatePassword">updatePassword</router-link>
   
  </p>
  <router-view></router-view>
</div>
</template>

<script>
export default {
  name: 'ProfileInfoComponent ',
}
</script>

my plugin ProfileInfo has following router:


import ProfileInfoComponent from '.ProfileInfo.vue';

//components
const UpdateEmail = { template: `<div class="foo"><h1>foo</h1></div>` }
const UpdatePassword = { template: `<div class="bar"><h1>bar</h1></div>` }


const router= new VueRouter({
  mode:history,
  routes: {
   path: '/ProfileInfo', component: ProfileInfoComponent ,

 children:  [
    { path: '/updateEmail', component: UpdateEmail },
    { path: '/updatePassword', component: UpdatePassword  }
  ]
}
})

//lib.ts
import ProfileInfoComponent from '.ProfileInfo.vue';

const MyProfilePlugin= {
  install(Vue, options) {
        Vue.component('ProfileInfoComponent', ProfileInfoComponent)
  }
}

export default MyProfilePlugin;

What is expected?

When i register a plugin , i was expecting all its routes will act in main app without any issue.

In my main app's main.ts file:

import ProfileInfoPlugin from 'ProfileInfoPlugin';

Vue.use(ProfileInfoPlugin , { testmsg:'hello world'});

The following link has code which is exactly what my plugin code looks like.. And i am trying to achieve this behaviour in any app which uses it .

https://jsfiddle.net/yyx990803/L7hscd8h/

What is actually happening?

But my main app is not aware of my plguin's routes and it throws below error when i click on 'updateEmail' link from my main app ProfileInfo page where it used my ProfileInfoComponent:

[vue-router] Route with name 'UpdateEmail' does not exist

@posva
Copy link
Member

posva commented Jun 6, 2020

Hi, thanks for your interest but Github issues are for bug reports and feature requests only. You can ask questions on the forum, the Discord server or StackOverflow.


You need to add the router to the main Vue https://router.vuejs.org/guide/

@posva posva closed this as completed Jun 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants