lazy-imports-mixin - Error: No imports found in the specified group
lazy-imports-mixin - Error: No imports found in the specified group
使用 Polymer 2 进行试验并使用来自 polymer cli 的示例应用程序,我将 Polymer.importHref
替换为惰性导入 mixin。但是,它抱怨 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));
}
我不知道这是否正确,但我使用 polymer cli 中的 polymer 2.0 示例应用程序,它默认带有惰性导入。尝试删除 lazy-imports-mixin 的导入和 lazy-import link 标签上的组属性。
<!-- <link rel="import" href="../bower_components/lazy-imports/lazy-imports-
mixin.html">
-->
<link rel="lazy-import" href="foo-element.html">
您的惰性导入组应该在 dom-module
之后但在 template
之前。像这样的东西:
<dom-module id="my-app">
<link rel="lazy-import" group="lazy" href="foo-element.html">
<template>
...
使用 Polymer 2 进行试验并使用来自 polymer cli 的示例应用程序,我将 Polymer.importHref
替换为惰性导入 mixin。但是,它抱怨 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));
}
我不知道这是否正确,但我使用 polymer cli 中的 polymer 2.0 示例应用程序,它默认带有惰性导入。尝试删除 lazy-imports-mixin 的导入和 lazy-import link 标签上的组属性。
<!-- <link rel="import" href="../bower_components/lazy-imports/lazy-imports-
mixin.html">
-->
<link rel="lazy-import" href="foo-element.html">
您的惰性导入组应该在 dom-module
之后但在 template
之前。像这样的东西:
<dom-module id="my-app">
<link rel="lazy-import" group="lazy" href="foo-element.html">
<template>
...