js和css的引入

use yii\helpers\Html;

1.全局引入,所有的view生效

  /assets/AppAsset.php

public $css = [
    'css/site.css',
    'css/style.css',
];
public $js = [
    'js/upload.js',
];

2.局部引入,在该view中生效 

 (1)

   <?=Html::jsFile('@web/***/js/***.js')?>//这里***代表你的目录名或者文件名

  <?=Html::cssFile('@web/***/css/***.css')?>//***同上

 (2)

    <?php $this->registerCssFile('@web/***/js/***.js');?>

  <?php $this->registerJsFile('@web/***/js/***.js');?>

 

 

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-05-25
  • 2021-10-06
  • 2021-06-27
  • 2021-10-04
  • 2021-09-26
相关资源
相似解决方案