Home  >  Article  >  Backend Development  >  Detailed explanation of the sample code for introducing bootstrap.js in Yii2 Advanced Edition

Detailed explanation of the sample code for introducing bootstrap.js in Yii2 Advanced Edition

黄舟
黄舟Original
2017-03-22 09:10:261955browse

This article mainly introduces a detailed explanation of how to introduce bootstrap.js in the advanced version of Yii2. It has certain reference value and interested friends can refer to it.

In frontend/assets/AppAsset.php

Code example

namespace frontend\assets;

use yii\web\AssetBundle;

/**
 * Main frontend application asset bundle.
 */
class AppAsset extends AssetBundle
{
  public $basePath = '@webroot';
  public $baseUrl = '@web';
  public $css = [
    'css/site.css',
  ];
  public $js = [
    'js/main.js',
  ];
  public $depends = [
    'yii\web\YiiAsset',
    'yii\bootstrap\BootstrapAsset',//注意这里必须要有
    'rmrevin\yii\fontawesome\AssetBundle',
  ];
}

In the vendor/yiisoft/yii2-bootstrap/BootstrapAsset.php file

namespace yii\bootstrap;

use yii\web\AssetBundle;

/**
 * Asset bundle for the Twitter bootstrap css files.
 *
 * @since 2.0
 */
class BootstrapAsset extends AssetBundle
{
  public $sourcePath = '@bower/bootstrap/dist';
  public $css = [
    'css/bootstrap.css',
  ];
  //下面是增加的代码
  public $js = [
    'js/bootstrap.js',
  ];
}

OK

The above is the detailed content of Detailed explanation of the sample code for introducing bootstrap.js in Yii2 Advanced Edition. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn