lazy-imports-mixin - 错误:在指定的组中找不到导入

时间:2018-01-25 05:12:45

标签: polymer polymer-2.x

试验聚合物2并使用聚合物cli中的样品应用程序,我用惰性导入mixin替换了Polymer.importHref。但是,它抱怨Error: No imports found in the specified group.

看起来很干燥,但我做错了什么?

   <link rel="import" href="../bower_components/lazy-imports/lazy-imports-
    mixin.html">

   <link rel="lazy-import" group="lazy" href="foo-element.html">
  <script>
    class MyApp extends Polymer.LazyImportsMixin(Polymer.Element) {
      static get is() { return 'my-app'; }

      static get properties() {
        return {
          page: {
            type: String,
            reflectToAttribute: true,
            observer: '_pageChanged',
          },
          routeData: Object,
          subroute: String,
          // This shouldn't be neccessary, but the Analyzer isn't picking up
          // Polymer.Element#rootPath
          rootPath: String,
        };
      }

      static get observers() {
        return [
          '_routePageChanged(routeData.page)',
        ];
      }

      _routePageChanged(page) {
        // If no page was found in the route data, page will be an empty string.
        // Default to 'view1' in that case.
        this.page = page || 'fooElement';

        // Close a non-persistent drawer when the page & route are changed.
        if (!this.$.drawer.persistent) {
          this.$.drawer.close();
        }
      }

      _pageChanged(page) {
        this.importLazyGroup('lazy').then((results) => {
        })
        .catch(e => console.log(e));
      }

2 个答案:

答案 0 :(得分:1)

您的懒惰导入组应该在dom-module之后但在template之前。类似的东西:

<dom-module id="my-app">
  <link rel="lazy-import" group="lazy" href="foo-element.html">
  <template>
  ...

答案 1 :(得分:0)

我不知道这是否正确,但我使用聚合物cli的聚合物2.0的样品应用程序,默认情况下它带有惰性进口。尝试删除lazy-imports-mixin的导入以及lazy-import链接标记上的group属性。

<!-- <link rel="import" href="../bower_components/lazy-imports/lazy-imports-
    mixin.html">
 -->
   <link rel="lazy-import" href="foo-element.html">