How to use router-vue.js
See original GitHub issueHello,
I’m trying to use the router-vue but I have some problems to dynamically load the right component. Would you have any advice for me, please?
I have something that works without require-vue, I don’t find how to import my vue file into my components routes !
`requirejs.config({ paths: { “Vue”: “./js/libraries/vue”, “vue”: “./js/libraries/require-vuejs”, “VueRouter”: “./js/libraries/vue-router” }, shim: { “Vue”: {“exports”: “Vue”} } });
require([“Vue”, “VueRouter”, ‘vue!./components/test.vue’, ‘vue!./components/HelloWorld.vue’], function(Vue, VueRouter){
const router = new VueRouter({
routes : [
{
path: '/',
name: 'test',
component: { template: '<div>foo</div>', name: 'test'}
},
{
path: '/hello',
name: 'hello',
component: { template: '<div>bar</div>', name: 'hello'}
}
]
})
Vue.use(VueRouter);
const app = new Vue({
router
}).$mount('#app');
});`
Thank you in advance
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Getting Started - Vue Router
Creating a Single-page Application with Vue + Vue Router feels natural: with Vue.js, we are already composing our application with components.
Read more >How to Use Vue Router: A Complete Tutorial - Vue School Blog
Let's create a new project and get right into coding. We'll create a new project with vue-cli. If you don't have it installed...
Read more >How to use vue-router? - CodinGame
Step 1: Make three components inside your components directory. · Step 2: We need to update the index.html file and add the app...
Read more >Vue JS 3 Tutorial for Beginners #8 - The Vue Router - YouTube
In this Vue 3 tutorial we'll take a look at the Vue Router in order to make a "multi-page" Vue website. We'll see...
Read more >How to use routing in Vue.js ? - GeeksforGeeks
App.vue ... The <router-view> can be used to display the routing components based on the routes. When applied to an element in a...
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
Thanks a lot @edgardleal, it works !
In your code you are registering yours components internally using
Vue.component('name', object)
. I recomend you to export your component as plain object like this:Now you can use with your current code, and with vue-router too.