vue.js - How do you import components having same name on Vue Router -
i'm working on vuejs project , structuring router records. i've realized having different components having same name. how import them , use them in route records? how make names unique when configuring router?
import vue 'vue' import router 'vue-router' import allusers '../components/sales/allusers' import allusers '../components/finance/allusers' ... export default new router({ routes: [ { path: '/', name: 'home', component: home }, { path: '/sales/users', name: 'sales-users', component: allusers }, { path: '/finance/users', name: 'finance-users', component: allusers }
i have used hypothetical example here (since call components salesusers
, financeusers
) agree there times when components have same name. how handle that, given need specify component each route record?
ps: new vuejs, advice on improvements , best practices welcome.
since exports default can choose name during import:
import vue 'vue' import router 'vue-router' import allsalesusers '../components/sales/allusers' import allfinanceusers '../components/finance/allusers' // ... export default new router({ routes: [ { path: '/', name: 'home', component: home }, { path: '/sales/users', name: 'sales-users', component: allsalesusers }, { path: '/finance/users', name: 'finance-users', component: allfinanceusers } ] })
Comments
Post a Comment