我在resources/js/router.js中有这个路由器代码
import Vue from 'vue';
import VueRouter from 'vue-router';
import ClientFeature1 from './components/ClientFeature1';
import ClientFeature2 from './components/ClientFeature2';
import InternalFeature1 from './components/InternalFeature1';
import InternalFeature2 from './components/InternalFeature2';
Vue.use(VueRouter);
export default new VueRouter({
routes : [
{ path : '/client-1', component : ClientFeature1, name : "Client Feature 1" },
{ path : '/client-2', component : ClientFeature2, name : "Client Feature 2" },
{ path : '/internal-1', component : InternalFeature1, name : "Internal Feature 1" },
{ path : '/internal-2', component : InternalFeature2, name : "Internal Feature 2" }
],
mode: 'hash'
});这可以很好地工作,但正如您所看到的,我加载了客户端的所有路由和仅供内部使用的路由。
如何仅在用户客户端或内部使用时加载?任何建议都是值得感谢的。
提前谢谢。
发布于 2021-02-01 18:31:55
export default new VueRouter({
routes : [
{
path : '/client-1',
name : "Client Feature 1"
// component : ClientFeature1, //asis
component: () => import(/* webpackChunkName: 'ClientFeature1' */'./components/ClientFeature1')
},
// ...
],
mode: 'hash'
});
https://stackoverflow.com/questions/65988424
复制相似问题