我有以下代码,到目前为止一切顺利:
import { Route } from '@vaadin/router';
import './views/object/list-view';
import './main-layout.ts';
export type ViewRoute = Route & {
title?: string;
children?: ViewRoute[];
};
export const views: ViewRoute[] = [
{
path: 'object',
component: 'list-view',
title: 'Objects',
},
{
path: 'dashboard',
component: 'dashboard-view',
title: 'Dashboard',
action: async () => {
await import('./views/dashboard/dashboard-view');
},
},
];
export const routes: ViewRoute[] = [
{
path: '',
component: 'main-layout',
children: views,
},
];
但是当添加如下附加内容时import './views/object2/list-view';
,它不起作用:
import { Route } from '@vaadin/router';
import './views/object/list-view';
import './views/object2/list-view';
import './main-layout.ts';
export type ViewRoute = Route & {
title?: string;
children?: ViewRoute[];
};
export const views: ViewRoute[] = [
{
path: 'object',
component: 'list-view',
title: 'Object',
},
{
path: 'object2',
component: 'list-view',
title: 'Object2',
},
{
path: 'dashboard',
component: 'dashboard-view',
title: 'Dashboard',
action: async () => {
await import('./views/dashboard/dashboard-view');
},
},
];
export const routes: ViewRoute[] = [
{
path: '',
component: 'main-layout',
children: views,
},
];
我认为它不起作用,因为导入了组件的名称。有没有办法在不更改组件名称的情况下澄清此文件中的差异?
我试过这个:
component: './views/object2/list-view'
但它仍然不起作用。
在此先感谢女士们先生们。