问题
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