canyin-project/ybcy/assets/AppAsset.php
2024-11-01 16:07:54 +08:00

52 lines
1.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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 <qiang.xue@gmail.com>
* @since 2.0
*/
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',
];
//定义按需加载JS方法注意加载顺序在最后
public static function addJs($view, $jsfile) {
$view->registerJsFile(
$jsfile,
[
AppAsset::className(),
"depends" => "backend\assets\AppAsset"
]
);
}
//定义按需加载css方法注意加载顺序在最后
public static function addCss($view, $cssfile) {
$view->registerCssFile(
$cssfile,
[
AppAsset::className(),
"depends" => "backend\assets\AppAsset"
]
);
}
}