我试图在Symfony 4中为我的网站的AdminCP实现AdminLTE。我执行了以下步骤:
composer require kevinpapst/adminlte-bundle ^2.0
cp vendor/kevinpapst/adminlte-bundle/config/packages/admin_lte.yaml config/packages/
.addEntry('adminlte', './assets/js/adminlte.js')
添加到了webpack.config.js
package.json
如下所示:此
{
"devDependencies": {
"@fortawesome/fontawesome-free": "~5.1.1",
"@symfony/webpack-encore": "^0.27.0",
"admin-lte": "~2.4.8",
"bootstrap-sass": "^3.3.7",
"bootstrap-select": "^1.13.1",
"daterangepicker": "^3.0.3",
"icheck": "^1.0.2",
"jquery-slimscroll": "^1.3.8",
"bootstrap": "^4.3.1",
"core-js": "^3.0.0",
"jquery": "^3.4.1",
"node-sass": "^4.12.0",
"popper.js": "^1.15.0",
"sass-loader": "^7.0.1",
"webpack-notifier": "^1.6.0"
},
"license": "UNLICENSED",
"private": true,
"scripts": {
"dev-server": "encore dev-server",
"dev": "encore dev",
"watch": "encore dev --watch",
"build": "encore production --progress"
},
"dependencies": {
"startbootstrap-blog-home": "^4.2.1"
}
}
跑了yarn install
。
为assets/js/adminlte.js
添加了require('../../vendor/kevinpapst/adminlte-bundle/Resources/assets/admin-lte');
Ran yarn encore dev
现在的问题是,布局根本无法正确呈现。例如,它在布局中具有正确的文本,但不能正确显示布局(请参见所附屏幕)。
See the problem with the layout here
在我的路线的控制器功能中呈现的模板仅包含以下内容:
{% extends 'admincp/base.html.twig' %}
admincp/base.html.twig
包含以下内容:
{% extends '@AdminLTE/layout/default-layout.html.twig' %}
{% block stylesheets %}
<link rel="stylesheet" href="{{ asset('build/adminlte.css') }}">
{% endblock %}
{% block javascripts %}
<script src="{{ asset('build/adminlte.js') }}"></script>
{% endblock %}
它不会引发错误或其他任何东西,但也不起作用。它请求并正确获取CSS和JS。
(如果需要更多信息,请询问,我会提供)。