[Vuejs]-Using <router-link> with vue-custom-element

2👍

You should inject the router to the component like that:

Vue.customElement('schools-widget', {
  router,
  render: h => h(App)
});

Update 1:
Just found out that you forgot to install the Vue router plugin:

Vue.use(VueRouter)
👤linhx

-3👍

import Vue from 'vue'
import VueRouter from 'vue-router'
import App from './App.vue'
import Schools from "./components/Schools";
import School from "./components/Schools";

const router = new VueRouter({
    routes: [
      { path: '/', component: Schools },
      { path: '/school', component: School },
    ]
  })
new Vue({
  router,
  render: (h) => h(App),
}).$mount('#app');

I think your code should be like this.

Leave a comment