编程语言
首页 > 编程语言> > PHP-Slim Framework 404 CSS问题

PHP-Slim Framework 404 CSS问题

作者:互联网

您好,所以我正在为一个简单的项目使用苗条的框架,目前遇到了问题.我的引发404错误的代码是:

$app->notFound(function () use ($app) {
    $app->render('404.html');
});

该代码将转到404页面,输入2个未知的url参数(例如website.com/1st/2nd/),但是当有3个或更多类似的website.com/1st/2nd/3rd/时,该代码仍然有效,但无法正常工作进行资产(css / js).

我的路线配置是这样的:

require_once 'vendor/autoload.php';

$app = new \Slim\Slim([
        'debug' => true,
        'templates.path' => 'app/views'
    ]);

$app->view = new \Slim\Views\Twig();
$app->view->setTemplatesDirectory("app/views");

$view = $app->view();
$view->parserOptions = ['debug' => true];
$view->parserExtensions = [new \Slim\Views\TwigExtension()];

我的观点是在使用树枝.我遵循了this教程.我的文件夹结构如下所示:

enter image description here

在我的基本模板中,这就是我包含资产(css / js)的方式.

enter image description here

它仅显示404页文本.这里有什么问题吗?

解决方法:

也许您应该使用base href,因为CSS和脚本源通常是相对的.

标签:slim,twig,css,php
来源: https://codeday.me/bug/20191119/2039569.html