【问题标题】:How to properly define a path to node_modules with polymer 3如何使用聚合物 3 正确定义 node_modules 的路径
【发布时间】:2018-07-10 20:05:12
【问题描述】:

我应该如何在我的 WebComponent 中使用聚合物 3 定义一个导入部分。

目前我有:

import {html, PolymerElement} from '@polymer/polymer/polymer-element.js';

我的目录结构如下:

我收到一个错误: (索引):7 GET http://127.0.0.1:8001/components/ing-dr-plan-details/node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js 404(未找到)

【问题讨论】:

    标签: javascript polymer polymer-3.x


    【解决方案1】:

    不是 100% 清楚您将聚合物配置放在哪里,但我假设您在 my-web-component 文件夹中拥有所有内容。即你的节点模块也应该在那个文件夹see also doc中。

    【讨论】:

      【解决方案2】:

      您拥有的导入代码

      import {html, PolymerElement} from '@polymer/polymer/polymer-element.js';
      

      并且错误彼此无关,终端抱怨缺少@webcomponentsjs 包。

      这是因为在 Polymer 3 中,@webcomponentsjs 包默认不再包含在 dependencies 中(它曾经在 Polymer 2 中)。您需要手动安装@webcomponentsjs

      npm install @webcomponentsjs

      【讨论】:

        猜你喜欢
        • 2018-11-21
        • 2018-11-17
        • 1970-01-01
        • 1970-01-01
        • 2016-10-26
        • 2018-12-17
        • 2020-07-29
        • 1970-01-01
        • 2022-01-25
        相关资源
        最近更新 更多