如何解决Symfony 4 webpack / encore加载错误?

时间:2018-11-23 16:44:16

标签: symfony webpack symfony4 webpack-encore

Symfony Webpack Encore出现问题,并且出现以下错误。

Loading failed for the <script> with source “http://localhost:8000/build/js/app.js”.

尝试同时使用或不使用资产。

 <script src="{{ asset('build/js/app.js') }}"></script>

尝试使用Firefox,Chrome。

2 个答案:

答案 0 :(得分:1)

好的,我找出了问题所在

我正在执行以下代码

{% block javascripts %}
      {{ encore_entry_script_tags('app') }}
      <script src="{{ asset('build/js/app.js') }}"></script>
{% endblock %}

在base.html.twig内, 但是后来,当我移到扩展了模板的模板时,它起作用了。

答案 1 :(得分:0)

您还尝试过这样使用它吗?

def cleanupstring(S):
counter = 0
lasti = ""
result = ""
for i in S:
    if lasti == " " and i == " ":
        i = ""
        counter += 1
    else:
        lasti = i
        result += i
return result, counter

sentence = input("Enter a string: ")
outputList = cleanupstring(sentence)

print("A total of", outputList[1], "characters have been removed from your string.")
print("The new string is:", outputList[0])