首先,我的项目使用的是Laravel框架。
我使用amp-list来动态呈现我的内容。这是我的模板的样子
@verbatim
<template type="amp-mustache" id="product-card-template">
<a class="no-underline db flex relative" href="{{ url }}" rel="nofollow">
<amp-img width="1" height="1" layout="responsive" class="center" src="{{ image }}" alt="{{ name }}">
</amp-img>
</a>
</template>
@endverbatim但这是浏览器呈现的
<a target="_top" rel="nofollow" href="https://dev-boost-my.iprice.mx/v2/levtop-back-support" class="no-underline db flex relative">
<amp-img alt="Back Support" src="" class="center i-amphtml-element i-amphtml-layout-responsive i-amphtml-layout-size-defined i-amphtml-built i-amphtml-layout amp-notsupported" layout="responsive" height="1" width="1" i-amphtml-ignore="" i-amphtml-layout="responsive">
<i-amphtml-sizer slot="i-amphtml-svc" style="padding-top: 100%;"></i-amphtml-sizer>
<img decoding="async" alt="Back Support" src="" class="i-amphtml-fill-content i-amphtml-replaced-content i-amphtml-ghost">
</amp-img>
</a>除了amp-img中的属性src之外,一切都很好。我可以确保字段{{ image }}不是空的,但一定程度上amp-mustache无法将其传递给amp-img。其他属性正在成功获取值。
发布于 2020-11-19 09:56:01
问题是我在src属性中放了空格,当我查看页面的源代码时,它的编码就像这样的src={{%20image%20}}。
我删除了空格,它工作得很好。仍然不知道为什么只有src属性编码空格,
发布于 2020-11-09 14:41:54
你有没有试过在留胡子的时候转义?不幸的是,我无法复制你的代码来检查,因为我不熟悉Laravel,但在我使用handlebars组合的实践中,这个技巧很有帮助,例如:
<a class="no-underline db flex relative" href="\{{url}}" rel="nofollow">
BRGDS,Vasily
https://stackoverflow.com/questions/64673785
复制相似问题