鉴于以下内容
@RouteConfig([
{ path: '/', name: 'root', redirectTo: ['Home'] },
{ path: '/home', name: 'Home', component: HomeComponent },
{ path: '/about', name: 'About', component: AboutComponent },
{ path: '/contact', name: 'Contact', component: ContactComponent },
{ path: '/protected', name: 'Protected', component: ProtectedComponent },
])
在dart中使用相同的代码会产生很多错误。什么是正确的飞镖码?为列表添加const不会更正错误
答案 0 :(得分:0)
在Dart中你需要引用地图键
{ 'path': '/', 'name': 'root', 'redirectTo': ['Home'] }
答案 1 :(得分:0)
尝试
@RouteConfig( const [
const Route(path: '/', name: 'root', redirectTo: ['Home']),
const Route(path: '/home', name: 'Home', component: HomeComponent),
const Route(path: '/about', name: 'About', component: AboutComponent),
const Route(path: '/contact', name: 'Contact', component: ContactComponent),
const Route(path: '/protected', name: 'Protected', component: ProtectedComponent)
])
答案 2 :(得分:0)
更正一个(没有Dart不支持的redirectTo):
@RouteConfig( const [
const Route(path: '/home', name: 'Home', component: HomeComponent, useAsDefault: true),
const Route(path: '/about', name: 'About', component: AboutComponent),
const Route(path: '/contact', name: 'Contact', component: ContactComponent),
const Route(path: '/protected', name: 'Protected', component: ProtectedComponent)
])