我尝试使用Polymer-2,并使用来自Polymer的示例应用程序,将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));
}发布于 2018-01-25 12:19:13
您的惰性导入组应该在dom-module之后,但在template之前。类似于:
<dom-module id="my-app">
<link rel="lazy-import" group="lazy" href="foo-element.html">
<template>
...发布于 2018-01-25 06:22:06
我不知道这是否正确,但我使用聚合物2.0的样例应用程序的聚合物cli,它与懒惰的进口默认。尝试删除延迟导入链接标签上的惰性导入-导入-混合和组属性。
<!-- <link rel="import" href="../bower_components/lazy-imports/lazy-imports-
mixin.html">
-->
<link rel="lazy-import" href="foo-element.html">https://stackoverflow.com/questions/48436058
复制相似问题