简体   繁体   English

在自己的项目中使用自定义聚合物元素-如何正确执行?

[英]Use custom polymer elements in own project - How to do it right?

So I found this nice port of Chart.js as a polymer component on customelements.io but I'm not able to use them in my polymer.dart project. 所以我发现chart.js之的这个漂亮的端口上的聚合物成分customelements.io ,但我不能在我polymer.dart项目中使用它们。 I copied all the files from the library project into my project and fixed the paths but the elements are not showing up. 我将所有文件从库项目复制到我的项目中,并修复了路径,但是元素未显示。 I get 我懂了

Uncaught ReferenceError: Polymer is not defined chart-bar.html:27(anonymous function) chart-bar.html:27

(+ same error for the other files from the library proj). (+对于库proj中的其他文件,存在相同的错误)。

I have no bower.json in my project (but a pubspec.yaml) and I'm wondering if I need one because the library project got one in there? 我的项目中没有bower.json(但是pubspec.yaml),我想知道是否需要一个,因为图书馆项目中有一个吗?

So what is the right way to get those polymer elements into my project? 那么将那些聚合物元素纳入我的项目的正确方法是什么?

There is currently no straight-forward way to use Polymer.js polymer elements in a Polymer.dart project. 当前,在Polymer.dart项目中没有直接使用Polymer.js聚合物元素的方法。 You can try to generate Dart wrappers using https://github.com/dart-lang/custom-element-apigen / https://pub.dartlang.org/search?q=custom-element-apigen . 您可以尝试使用https://github.com/dart-lang/custom-element-apigen/ https://pub.dartlang.org/search?q=custom-element-apigen生成Dart包装器。

The code generation depends on proper JavaScript codedoc in the JS elements which is often incomplete but I have heard of people who were satisfied by the result (Dart core_elements/paper_elements are generated with this but there is also manual work involved). 代码生成取决于JS元素中正确的JavaScript代码文档,而这通常是不完整的,但我听说有人对此结果感到满意(Dart core_elements / paper_elements是由此生成的,但也涉及手动工作)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM