我创建了一个包含Encore Webpack的Symfony 4项目。我的项目中的微博页面模板如下所示。如您所见,我使用holder.js来显示图像占位符,但它们根本不显示。
{% extends 'base.html.twig' %}
{% block body %}
{% for post in posts %}
<div class="media text-muted pt-3">
<img data-src="holder.js/32x32?text=MJ&bg=e83e8c&fg=fff&size=8" alt="" class="mr-2 rounded">
<p class="media-body pb-3 mb-0 small lh-125 border-bottom border-gray">
<span class="d-block"><strong class="text-gray-dark">@username</strong> <small>{{ post.time|date("d/m/y") }}</small></span>
{{ post.text }}
</p>
</div>
{% endfor %}
{% endblock %}
webpack.config.js
.addEntry('app', [
'./node_modules/jquery/dist/jquery.slim.js',
'./node_modules/popper.js/dist/popper.min.js',
'./node_modules/bootstrap/dist/js/bootstrap.min.js',
'./node_modules/holderjs/holder.min.js'
])
.addStyleEntry('css/app', [
'./node_modules/bootstrap/dist/css/bootstrap.min.css',
'./assets/css/app.css'
])