带撇号-cms的静态图像

时间:2019-04-10 08:37:11

标签: apostrophe-cms

我已经读过Guide for pushing assets,但并没有帮助我。我想更改代码中的下拉箭头。

<div class="filter-dropdown">
    <select class="filter-select select-borders-styles">
        <option value="newest">Newest First</option>
        <option value="oldest">Oldest First</option>
    </select>
</div>

这是较少的代码:

.filter-dropdown{
      [...]

        .filter-select{
            background: url('/modules/my-module/public/img/my-image.png') no-repeat 96% 0;
            overflow: hidden;
            width: 240px;
            padding: 20px;
            font-size: 19px;
            -webkit-appearance: none;  /*Removes default chrome and safari style*/
            -moz-appearance: none;   /*Removes default style Firefox*/
            color: #0167C2;  

            select{
                [..]
            }
        }

        .select-borders-styles{
           [...]
        }
}

我已经看到必须在/my-module/public/img/my-image.png上添加图像,我已经添加了图像,并在更少的文件中添加了具有正确路径的url,但是它不起作用。

如果我在de index.js文件中添加代码,例如添加.less则此代码:

    self.pushAssets = function() {
      superPushAssets();
      self.pushAsset('img', 'options_arrow', { when: 'always' });
    };

它显示此错误:

    /home/kalia/Escritorio/leo-newsletter/newsletter/node_modules/apostrophe/index.js:75
        throw err;
        ^
TypeError: Cannot read property 'fs' of undefined
    at Object.self.push (/home/kalia/Escritorio/leo-newsletter/newsletter/node_modules/apostrophe/lib/modules/apostrophe-assets/index.js:497:67)

有人可以告诉我我在做什么错吗?谢谢。

1 个答案:

答案 0 :(得分:1)

pushAsset方法适用于CSS文件和javascript,不适用于图像。因此该代码将无法正常工作。但是,您不需要它。它仅用于将内容组合成束,以单个文件的形式提供,这不是图像所需的功能。

如果您在lib/modules/mymodulename/public/my.png处有图片,则可以使用以下URL引用它:/modules/mymodulename/my.png

之所以可行,是因为Apostrophe在启动时将模块的public文件夹复制或符号链接到/modules/...,具体取决于操作系统。

请注意,URL 不包含/public/lib。仅/modules/mymodulename/...。如果需要,可以有一个images子目录,在这种情况下,它应该是/modules/mymodulename/images/my.png(也就是说,文件名中 public之后的所有内容都需要在网址中)。

相关问题