0

我目前面临以下问题:

我在src/assets/images/img.png. 在我想要显示图像的片段中,我写了这个(如文档中所定义):

<img src="{{ '../assets/images/img.png' | asset_url }}"/>

执行时slate build,我还可以在日志中的构建过程中看到这些图像。但是当我启动我的开发服务器 ( npm run start:dev) 时,图像的链接已损坏并且不会显示。关于如何解决这个问题的任何想法?

4

1 回答 1

0

Your link is built all wrong. The Liquid filter asset_url resolves the path for you. All you need to provide is the name of the asset. So if you rewrite your Liquid correctly it would look like this:

{{ 'img.png' | asset_url }}

Reads as hey Shopify, go find img.png in the assets and return for me the complete path to it.

于 2018-07-05T17:08:03.637 回答