如有问题可继续追问,纯手打,望采纳 谢谢!
namespace backend\assets
use yii\web\AssetBundle
/**
* @author chan <maclechan@qq.com>
* @since 2.0
*/
class AppAsset extends AssetBundle
{
public $basePath = '@webroot'
public $baseUrl = '@web'
//全局CSS
public $css = [
'css/animate.css',
'css/style.min.css',
]
//全局JS
public $js = [
'js/jquery-2.1.1.js'
]
//依赖关系
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
]
//定义按需加载JS方法,注意加载顺序在最后
public static function addScript($view, $jsfile) {
$view->registerJsFile($jsfile, [AppAsset::className(), 'depends' =>'api\assets\AppAsset'])
}
//定义按需加载css方法,注意加载顺序在最后
public static function addCss($view, $cssfile) {
$view->registerCssFile($cssfile, [AppAsset::className(), 'depends' =>'api\assets\AppAsset'])
}
}