gpt4 book ai didi

php - Symfony 2.8 app no style 加载资源失败

转载 作者:行者123 更新时间:2023-11-28 03:34:07 26 4
gpt4 key购买 nike

我正在 Dev env 中开发一个 Symfony 2.8 应用程序,除未设置样式外,所有内容均已加载。 Javascript 和 CSS 文件似乎无法加载。

这是我的base.html.twig 文件:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>{% block meta_title %}Welcome!{% endblock %}</title>
<link href="{{ asset('public/bootstrap/dist/css/bootstrap.min.css') }}" rel="stylesheet">
<link href="{{ asset('public/bootstrap-table/dist/bootstrap-table.min.css') }}" rel="stylesheet">
<link href="{{ asset('public/components-font-awesome/css/font-awesome.min.css') }}" rel="stylesheet">
<link href="{{ asset('public/select2/select2.css') }}" rel="stylesheet">
<link href="{{ asset('bundles/admin/css/select2-bootstrap.css') }}" rel="stylesheet">
<link href="{{ asset('bundles/admin/css/styles.css') }}" rel="stylesheet">
<link href="{{ asset('public/multiselect/css/multi-select.css') }}" rel="stylesheet">
{% block stylesheets %}
{% endblock %}
<script src="{{ asset('public/jquery/dist/jquery.min.js') }}"></script>
<script src="{{ asset('public/bootstrap/dist/js/bootstrap.min.js') }}"></script>
<script src="{{ asset('public/bootstrap-table/dist/bootstrap-table.min.js') }}"></script>
<script src="{{ asset('public/bootstrap-table/dist/extensions/cookie/bootstrap-table-cookie.min.js') }}"></script>
<script src="{{ asset('public/jquery.maskedinput/src/jquery.maskedinput.js') }}"></script>
<script src="{{ asset('public/select2/select2.min.js') }}"></script>
<script src="{{ asset('public/moment/min/moment.min.js') }}"></script>
<script src="{{ asset('public/multiselect/js/jquery.multi-select.js') }}"></script>
{% block top_javascripts %}
{% endblock %}
<link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
</head>
<body class='skin-blue sidebar-mini'>
<noscript>
<div class="global-site-notice noscript">
<div class="notice-inner">
<p>
<strong>JavaScript is disabled in your browser.</strong><br>
Please enable JavaScript settings in your browser to allow this website work correctly.
</p>
</div>
</div>
</noscript>
<div class='wrapper'>
{% block body %}{% endblock %}
<footer class="navbar-fixed-bottom footer text-muted main-footer">
&copy;&nbsp;{{ "now"|date("Y") }} TCX - All rights reserved &nbsp;&nbsp;&nbsp;•&nbsp;&nbsp;&nbsp;Version-
1.1.133
</footer>
</div>
{% block bottom_javascripts %}
<script src="{{ asset('public/jquery-slimscroll/jquery.slimscroll.min.js') }}"></script>
<script src="{{ asset('bundles/fosjsrouting/js/router.js') }}"></script>
<script src="{{ path('fos_js_routing_js', { callback: 'fos.Router.setData' }) }}"></script>
<script src="{{ asset('bundles/admin/js/scripts.js') }}"></script>
{% endblock %}

<!-- form focus -->
<script type="text/javascript">
if($('form:first .has-error').length == 0) {
$('form:first *:input[type!=hidden]:enabled:first').focus();
}
</script>

<----------------------------------------> < strong>这是我的 Bower.JSON:

</body>
</html>
{
"name": "NULL",
"authors": [
"NULL"
],
"description": "",
"main": "",
"license": "MIT",
"homepage": "",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"bootstrap": "^3.3.7",
"components-font-awesome": "^4.6.3",
"jquery-slimscroll": "^1.3.8",
"bootstrap-table": "^1.0.0",
"bootstrap-fileinput": "^4.3.5",
"jquery-timepicker-jt": "^1.11.0",
"datepair.js": "^0.4.0",
"jquery.maskedinput": "^1.4.*",
"select2": "3.2",
"moment": "2.17.1",
"fullcalendar": "3.1.0",
"fullcalendar-scheduler": "1.5.0",
"multiselect": "0.9.12"
}
}

所需的 Javascript 和 CSS 文件位于此 Bower.JSON 文件中。所以我运行了 Bower Install 并将所有包安装到 public/但是,当我去运行应用程序时 php app/console server:run 一切都在运行,但缺少样式。

已经尝试清除缓存 php app/console cache:clear & php app/console assets:install web。非常感谢所有帮助!

Picture of Error Log from Safari

最佳答案

解决方案是将 Bower 组件安装在 web/public 下。在它们安装在 public/ 下之前。

重要的是要注意,如果您使用 Symfony 部署应用程序,请确保所需的包位于 web 文件夹下。

关于php - Symfony 2.8 app no style 加载资源失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44576262/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com