我正在尝试在yii2基本应用程序中使用Architect Free Template。
使用标签时出现问题
<?php $this->beginBody() ?> and <?php $this->endBody() ?>
如上图所示,它使身体的内容非常小:
如果我不使用标签,则如下所示:
如果我不使用标记,则Javascript事件(如验证)将无法正常工作。
那么在这种情况下我该怎么办?
Main.php
码:
<?php
use app\assets\AppAsset;
use yii\helpers\Html;
use yii\web\YiiAsset;
use app\widgets\Alert;
AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="<?= Yii::$app->charset ?>">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, shrink-to-fit=no" />
<meta name="msapplication-tap-highlight" content="no">
<?php $this->registerCsrfMetaTags() ?>
<title><?= Yii::$app->name ?> - <?= Html::encode($this->title) ?></title>
<?php $this->head() ?>
</head>
<body>
<?= $this->render('cabecera') ?>
<?= $this->render('menu') ?>
<div class="app-main__outer">
<div class="app-main__inner">
<div class="app-page-title">
<div class="page-title-wrapper">
<?= Alert::widget() ?>
<?= $content ?>
</div>
</div>
</div>
<?= $this->render('footer') ?>
</div>
</body>
</html>
<?php $this->endPage() ?>
更新:
我检查了AppAsset.php文件,并注意到是否在注释行“ yii \ bootstrap \ BootstrapAsset”的注释中将正文页恢复为正常,但没有任何引导样式。
AppAsset.php:
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace app\assets;
use yii\web\AssetBundle;
/**
* Main application asset bundle.
*
* @author Qiang Xue <[email protected]>
* @since 2.0
*/
class AppAsset extends AssetBundle
{
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
// 'css/site.css',
'css/main.css',
];
public $js = [
'js/main.js',
];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset', //I have the issue with this one
'yii\web\JqueryAsset',
];
// public $jsOptions = array(
// 'position' => \yii\web\View::POS_HEAD
// );
}
抱歉,我发现了它失败的原因,如@ustmaestro所说,yii2具有不同的引导程序版本,并且模板使用bootstrap4。
安装yii2 bootstrap4软件包后,它可以完美运行。
必须更改代码以插入bootstrap4函数。
问候。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句