【问题标题】:Images in npm package not displayed in Meteor appnpm 包中的图像未显示在 Meteor 应用程序中
【发布时间】:2016-10-01 04:13:19
【问题描述】:

我正在尝试将我的一些氛围包迁移到 npm 包中,并遇到了一些图像未加载到 npm 包uploadcare-widget 中的问题。该包引用文件夹node_modules/uploadcare-widget/images 中的图像。图片通过css显示在页面上,例如:

.uploadcare-dialog-file-sources:before {
  background-image: url("node_modules/uploadcare-widget/images/arrow.png");
}

我可以看到我的应用尝试从网络检查器加载图像,但图像没有从显示的路径加载。我可以确认图像文件在指定的文件目录中。为了能够从 npm 包中加载图像,我需要做些什么特别的事情吗?

我在公用文件夹中尝试了import 'node_modules/uploadcare-widget/images'; 和其他变体。我可能最终会回到使用大气包:\

【问题讨论】:

  • 目前,您可能需要将它们复制到public 文件夹。注意public/ 文件夹映射到根目录,所以public/foo.png 应该被称为/foo.png

标签: meteor npm uploadcare


【解决方案1】:

您可能会像在readme 中一样使用UPLOADCARE_SCRIPT_BASE,但可能是错误的方式。

尝试只使用这段代码

import uploadcare from 'uploadcare-widget'

而不是类似自述文件的代码。

【讨论】:

    猜你喜欢
    • 2015-07-08
    • 2017-03-21
    • 2018-07-15
    • 2014-02-08
    • 2018-02-02
    • 1970-01-01
    • 1970-01-01
    • 2019-08-01
    • 1970-01-01
    相关资源
    最近更新 更多