【发布时间】:2016-03-06 01:49:18
【问题描述】:
有没有人成功地将 Polymer 元素添加到 Meteor 项目中?我正在努力让它发挥作用。
我尝试使用 bower 在 public 下安装 Polymer 包:
├── public
│ ├── bower_components
│ │ ├── platform
│ │ └── polymer
│ ├── elements
│ │ └── my-element.html
然后我包含这样的元素:
<head>
<title>test</title>
<script src="bower_components/platform/platform.js"></script>
<link rel="import" href="elements/my-element.html">
</head>
<body>
...
<my-element></my-element>
...
</body>
这会导致对 platform.js 和 my-element.html 的 XHR 请求无限循环。
我也尝试过meteor-polymer 包,它不包含polymer.html,但我无法让它识别包:
=> Errors prevented startup:
While building the application:
error: no such package: 'polymer'
我希望有人能够让 Polymer 与 Meteor 一起使用,因为我真的很想在这个应用程序中使用我的组件。
【问题讨论】:
-
您正在尝试使用 Polymer 真是太酷了。然而,在我看来,“Meteor 方式”在很大程度上依赖于模板——只要有一点耐心,Meteor 和 Angular(以及其他)都会看起来更像 Polymer。
-
同意@dalgard,Meteor 的 Blaze UI 有一些令人兴奋的功能即将推出,这将使其可用作强大的组件系统。 Meteor 做了很多棘手的事情来使其反应式 HTML 模板工作,所以我不确定何时/是否可以像这样/可能与 Polymer 兼容。我怀疑你最好的选择是完全绕过 Meteor 的模板引擎并自己连接它,无论 Polymer 支持它的任何方式。但是请注意:您是使用 Meteorite 还是尝试使用香草 Meteor 安装软件包?阅读:atmosphere.meteor.com/wtf/app
-
@dalgard,我想我正在尝试更多 Meteor,并希望我可以重复使用一些 Polymer 元素。
-
@Cuberto,感谢您的回复。我会看一下 Blaze,但我觉得我可以将 Meteor 用于一个更简单的项目,我不会将两种新兴技术结合起来。我使用 Meteorite 安装它,如 Readme 中所述。
-
@jamstoks Blaze 只是 Meteor 的全新官方模板系统。它只是对模板引擎的重写,与当前系统相比提供了几个好处。它目前是 WIP,但将在 Meteor 1.0 中包含在 Meteor 核心中。你可以在这里阅读:github.com/meteor/meteor/wiki/New-Template-Engine-Preview
标签: javascript meteor polymer