Home > Backend Development > PHP Tutorial > 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

黄舟
Release: 2023-03-06 19:58:01
Original
2001 people have browsed it

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',
  ];
}
Copy after login

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',
  ];
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template