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 backend\assets;

use yii\web\AssetBundle;

/**
 * @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 = [
        'yii\web\JqueryAsset',//依赖
    ];
}

 

2、执行引入

CollectionAsset::register($this->view);

3、在js脚本中写入程序

相关文章:

  • 2022-12-23
  • 2021-10-06
  • 2021-06-22
  • 2021-08-19
  • 2022-12-23
猜你喜欢
  • 2021-09-08
  • 2021-07-14
  • 2021-10-09
  • 2021-12-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案