gpt4 book ai didi

dart - .template.dart文件未创建

转载 作者:行者123 更新时间:2023-12-03 03:26:35 25 4
gpt4 key购买 nike

我正在尝试使Routes类正常工作。
当我尝试导入
import 'package:mango/src/component/pages/dashboard_component.template.dart' as dashboard_template;
我收到此错误:

[SEVERE] build_web_compilers|entrypoint on web/main.dart:
Unable to find modules for some sources, this is usually the result of either a
bad import, a missing dependency in a package (or possibly a dev_dependency
needs to move to a real dependency), or a build failure (if importing a
generated file).

Please check the following imports:

`import 'src/component/pages/dashboard_component.template.dart' as _ref3;` from mango|lib/app_component.template.dart at 19:1
`import 'package:mango/lib/src/component/pages/dashboard_component.template.dart' as dashboard_template;` from mango|lib/src/routes.template.dart at 9:1
`import 'package:mango/lib/src/component/pages/dashboard_component.template.dart' as dashboard_template;` from mango|lib/src/routes.dart at 5:1

并查看构建目录结构后,我注意到尚未创建dashboard_component.template.dart,而其他所有文件均已创建。

lib / src / routes.dart
import 'package:angular_router/angular_router.dart';
import 'package:mango/src/component/pages/dashboard_component.template.dart' as dashboard_template;
import 'route_paths.dart';
export 'route_paths.dart';

class Routes {
static final dashboard = RouteDefinition(
routePath: RoutePaths.dashboard,
component: dashboard_template.DashboardComponentNgFactory,
useAsDefault: true,
);

static final all = <RouteDefinition>[
dashboard,
];
}

lib / src / component / pages / dashboard_component.dart
import 'package:angular/angular.dart';
import '../customers/customers_component.dart';
import '../customers/new_customer_component.dart';
import '../../data_service.dart';

@Component(
selector: 'dashboard',
templateUrl: 'dashboard_component.html',
providers: [
CustomersComponent,
NewCustomerComponent,
],
)
class DashboardComponent {
final DataService _dataService;

DashboardComponent(this._dataService);
}

lib / app_component.dart
import 'package:angular/angular.dart';
import 'package:angular_router/angular_router.dart';

import 'src/component/header/header_component.dart';
import 'src/component/pages/dashboard_component.dart';
import 'src/model/customer.dart';
import 'src/data_service.dart';
import 'src/routes.dart';

@Component(
selector: 'app',
templateUrl: "app_component.html",
styleUrls: ['app_component.css'],
directives: [
coreDirectives,
routerDirectives,
HeaderComponent,
DashboardComponent,
],
providers: [ClassProvider(DataService)],
exports: [RoutePaths, Routes],
)
class AppComponent implements OnInit {
final DataService dataService;

List<Customer> get customers => dataService.customers;

AppComponent(this.dataService);

@override
ngOnInit() {
dataService.init();
}
}

我搜索了其他线程,但找不到任何有用的信息。

最佳答案

我认为您的.html中有错误,因此模板未在.dart_tools / build / generated中生成

删除.dart_tools / build文件夹。然后在命令行上执行-

 pub run build_runner build --delete-conflicting-outputs

这应该显示一些错误。如果不是,则必须手动检查html文件中的语法

同时检查.dart文件中是否列出了所有正确的指令和提供程序

关于dart - .template.dart文件未创建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52470048/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com