How i use web-components in MeteorJS?

早过忘川 提交于 2019-12-13 18:43:46

问题


I am coding in MeteorJS & using Google's Polymer as frontend framework, Polymer web-component syntax contains <template> tag

<dom-module>
    <template>
<!-- html code -->
    </template>
</dom-module>

MeteorJS not allowing to write <template> tag inside <dom-module> & shows error

While processing files with templating (for target web.browser): client/test.html:1: Expected one of: <body>, <head>, <template>

How i solve this ?


回答1:


The following works for me.

Put all Polymer related files inside the public folder on your Meteor app. Something like that:

.
├── .meteor
├── client
├── server
└── public
    ├── bower.json
    ├── bower_components
    │   ├── iron-icons
    │   ├── polymer
    │   ├── webcomponentsjs
    │   └── web-component-tester
    └── elements
        └── elements.html

Add the following code to a head tag:

<script src="/bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="/elements/elements.html">

And do all Polymer elements imports in the elements.html file:

<link rel="import" href="../bower_components/iron-icons/iron-icons.html">

I hope it helps you.



来源:https://stackoverflow.com/questions/34313557/how-i-use-web-components-in-meteorjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!