1、在 /backend/assets/ 中新建一个文件 CollectionAsset.php
<?php /** * @link http://www.yiiframework.com/ * @copyright Copyright (c) 2008 Yii Software LLC * @license http://www.yiiframework.com/license/ */ namespace backendassets; use yiiwebAssetBundle; /** * @author Qiang Xue <qiang.xue@gmail.com> * @since 2.0 */ class CollectionAsset extends AssetBundle { public $basePath = '@webroot'; public $baseUrl = '@web'; public $css = [ ]; public $js = [ 'js/collection.js'//需要引入的js文件 ]; public $depends = [ 'yiiwebJqueryAsset',//依赖 ]; }
2、执行引入
CollectionAsset::register($this->view);
3、在js脚本中写入程序