Using vue-router with vue-custom-element
See original GitHub issueI’m very new to Vue and am trying to create a Vue app that can be embedded inside a non Vue app. I am having trouble getting routing to work inside of my Vue app.
I have two components in my app - Schools and School.
in main.js I have this:
import Vue from 'vue'
import VueRouter from 'vue-router'
import App from './App.vue'
import vueCustomElement from 'vue-custom-element'
import Schools from "./components/Schools";
import School from "./components/Schools";
Vue.use(vueCustomElement);
const router = new VueRouter({
routes: [
{ path: '/', component: Schools },
{ path: '/school', component: School },
]
})
App.router = router;
Vue.customElement('schools-widget', App)
and then in my schools component (Schools.vue) I have
<router-link to="/school">School</router-link>
which I was hoping would link me from my Schools component to my School component.
But I get the error
Unknown custom element: <router-link> - did you register the component correctly?
Are you able to tell me what I am doing wrong?
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Using <router-link> with vue-custom-element - Stack Overflow
I have two components in my app - Schools and School. in main.js I have this: import Vue from 'vue' import VueRouter from...
Read more >Using the router *inside* of an Custom Element #19 - GitHub
Is there a way to use the router inside of an Custom Element? ... import Vue from 'vue' import VueRouter from 'vue-router' import...
Read more >Vue and Web Components
A Vue custom element will mount an internal Vue component instance inside its shadow root when the element's connectedCallback is called for the...
Read more >Using Custom Elements in Vue.js - bitspeicher.blog
Custom Elements are part of the Web Component specification and allow the use of custom HTML tags. After defining them, they are used...
Read more >vue-custom-element - npm
Vue -custom-element is a tiny wrapper around Vue components. It provides a seamless way to use Vue components in HTML, plain JavaScript, Vue, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for your help - someone helped me with an example and my code works now!
https://stackoverflow.com/questions/66624187/using-router-link-with-vue-custom-element
Great!