【问题标题】:pub serve not finding files under libpub 服务在 lib 下找不到文件
【发布时间】:2015-07-29 01:36:50
【问题描述】:

我正在使用 Angular 版本 2 的开发者预览版进行测试,并使用 pub serve 提供它

我想建立一个约定来在 /lib/ 中构建我的文件,如下所示:

└── project/lib/root
    ├── root.css
    ├── root.dart
    └── root.html
└── project/web/
    ├── index.html
    └── index.dart

在我的 /web/index.dart 文件中,我能够成功地从 root.dart 初始化 @View 和 @Component

但是,当我通过 pub serve 在 Dartium 中预览时 - 我似乎无法提供 /lib/root/root.html

@Component(
    selector: 'jroot'
)
@View(
    templateUrl: '../../lib/root/root.html',
    directives: const [If]
)
class Root {
  String content = 'Root - This is the entry point to the component';
  List<Times> list;

  Root(){
    print('RootComponent Init');
  }
}

Dartium 控制台:

GET http://localhost:8080/lib/root/root.html 404 (Not Found)

我一直在阅读有关聚合物的文件,其中指出:

"lib下的非Dart文件必须使用相对路径导入lib下的assets:"

https://www.dartlang.org/polymer/app-directories.html

<!-- lib/a5/a6/a6.html imports lib/a4.html -->
<link rel="import" href="../../a4.html">

运行 python 简单的 web 服务器似乎可以工作,所以问题在于 pub serve:

python -m SimpleHTTPServer

问题:配置 pub 如何使用 lib 文件夹中的嵌套 html 文件?

【问题讨论】:

    标签: dart angular


    【解决方案1】:

    确保您的 pubspec.yaml 转换器上有正确的入口点:

    name: 'project'
    version: 0.0.1
    dependencies:
      angular2: '2.0.0-alpha.23'
      browser: any
    transformers:
    - angular2:
        entry_points:
            - web/index.dart  //this
        reflection_entry_points:
            - web/index.dart  //this
    

    那我觉得应该可以了

    templateUrl: 'packages/project/root/root.html',
    

    或者只是

    templateUrl: 'root.html',
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-08-22
      • 2023-03-20
      • 1970-01-01
      • 2017-06-30
      • 1970-01-01
      • 1970-01-01
      • 2020-02-14
      • 1970-01-01
      相关资源
      最近更新 更多