gpt4 book ai didi

javascript - 我如何在MeteorJS中使用Web组件?

转载 作者:行者123 更新时间:2023-11-28 06:35:38 25 4
gpt4 key购买 nike

我使用MeteorJS进行编码,并使用Google的Polymer作为前端框架,Polymer Web组件语法包含<template>标记

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


MeteorJS不允许在 <template>中写入 <dom-module>标记并显示错误

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


我该如何解决?

最佳答案

以下对我有用。

将所有与Polymer相关的文件放在Meteor应用程序的public文件夹中。像这样:

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


将以下代码添加到 head标记中:

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


并在 elements.html文件中导入所有Polymer元素:

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


希望对您有帮助。

关于javascript - 我如何在MeteorJS中使用Web组件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34313557/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com