问题描述
我从git复制了一个存储库,前端似乎还可以,但是在后端我有AppAsset的问题
AppAsset文件:
<?PHP
namespace backend\assets;
use yii\web\AssetBundle;
/**
* Main backend application asset bundle.
*/
class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/site.css',];
public $js = [
];
public $depends = [
'yii\web\YiiAsset','yii\bootstrap\BootstrapAsset',];
}
布局main.PHP文件,我只在h1中保留了“ Hello world”以测试CSS
<?PHP
/* @var $this \yii\web\View */
/* @var $content string */
use backend\assets\AppAsset;
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use common\widgets\Alert;
AppAsset::register($this);
?>
<?PHP $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
<Meta charset="<?= Yii::$app->charset ?>">
<Meta http-equiv="X-UA-Compatible" content="IE=edge">
<Meta name="viewport" content="width=device-width,initial-scale=1">
<?PHP $this->registerCsrfMetaTags() ?>
<?PHP $this->registerCssFile("@backend/web/css/site.css") ?>
<?PHP /*$this->registerCss("body { background: #f00; }") */?>
<title><?= Html::encode($this->title) ?></title>
<?PHP $this->head() ?>
</head>
<body>
<?PHP $this->beginBody() ?>
<h1>Hello world</h1>
<?PHP $this->endBody() ?>
</body>
</html>
<?PHP $this->endPage() ?>
在web / css / site.css结尾,我添加了以下代码:
h1{
background: red;
}
body{
background: red;
}
我觉得问题可能出在AppAssets配置上。我也是yii和
的新手不起作用: <?PHP $this->registerCssFile("@web/css/site.css") ?>
作品: <?PHP $this->registerCss("body { background: #f00; }") ?>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)