1.配置文件中做相关的配置/frontend/config/params.php
<?php
return [
'title'=>'title',
'Keywords'=>'Keywords',
'description'=>'description',
]
2.获取
<title><?= Yii::$app->params['title'] ?></title>
<meta name="Keywords" content="<?= Yii::$app->params['Keywords'] ?>">
<meta name="Description" content="<?= Yii::$app->params['description'] ?>">
3.重新赋值
Yii::$app->params['title'] = '空气消毒机,移动式空气消毒机';
Yii::$app->params['Keywords'] = '空气消毒机,移动式空气消毒机';
Yii::$app->params['description'] = '空气消毒机,移动式空气消毒机';