angular - 路由错误 - 类型“字符串”不可分配给类型“类型”'
问题描述
无法解决此问题,每当我尝试使用此路由方法时,它都会显示错误,例如
输入'{路径:字符串;组件:趋势组件的类型;}' 不可分配给类型 'Route'。对象字面量只能指定已知属性,并且“路径”类型中不存在“路径”。
export const MODULE_ROUTES: Route[] = [
{ path: 'trends', component: TrendsComponent },
{ path: 'customtrend', component: CustomtrendComponent },
{ path: '**', redirectTo: 'trends', pathMatch: 'full' }
];
解决方案
将 'Route[]' 更改为 'Routes','Routes' 已经是一个对象类型数组。
'Routes' 应该以这种方式导入: import { Routes } from '@angular/router'。
推荐阅读
- python - 并行处理 Airflow 上的百万个文件列表
- ruby-on-rails - Rails:在视图中显示按日期排序的两个查询的组合
- java - 从firebase检索数据到arraylist
- java - java中如何与另一个进程通信?
- sql - 如何在 t-sql 上的联合子句上获得更好的性能
- spring-security - 如何使用自定义 Spring Boot 登录表单调用控制器发布方法
- android - 如何将字符串数组列表从适配器发送到它自己的活动
- selenium - 如何在单击 span 元素时停止 Selenium
- wordpress - WordPress 地址 (URL) 设置干扰了 Let's Encrypt 的挑战
- laravel - 按特定页码获取分页数据