1,定义资源:首先在AppAsset.php里面定义2个方法, //按需加载css public static function addCss($view, $cssfile) { $view->registerCssFile($cssfile, [AppAsset::className(), 'depends' => 'backend\assets\AppAsset']); } //按需加载js //定义按需加载JS方法,注意加载顺序在最后 public static function ad…