zoukankan      html  css  js  c++  java
  • Yii2 加载bootstrap.js

    问题:加载了 frontendassetsAppAsset 资源包,但是 bootstrap.js 文件没有被加载,打开 vendoryiisoftyii2-bootstrapsrcBootstrapAsset.php,只加载了 css/bootstrap.css。

    但是首页会自动载入bootstrap.js文件,后来发现因为在 layout/main.php 中用到了 NavBar(导航)组件,在导航中会依赖 bootstrap 的 js 包。
    解决方法:使用 /vendor/yiisoft/yii2-Bootstrap/BootstrapPluginAsset.php

    在frontendassetsAppAsset.php中,引入'yiiootstrapBootstrapPluginAsset',

    <?php
    namespace frontendassets;
    use yiiwebAssetBundle;
    
    /**
     * Main frontend application asset bundle.
     */
    class AppAsset extends AssetBundle
    {
        public $basePath = '@webroot';
        public $baseUrl = '@web';
        public $css = [
            'css/site.css',
        ];
        public $js = [
        ];
        public $depends = [
            'yiiwebYiiAsset',
            'yiiootstrapBootstrapAsset',//bootstrap.css
            'yiiootstrapBootstrapPluginAsset',//bootstrap.js
        ];
    }
    
    

    参考:
    https://qa.1r1g.com/sf/ask/2122944701

  • 相关阅读:
    iOS 之 创建分类
    iOS 之 动画
    iOS 倒出spa文件 打包
    js闭包
    wampserver配置多站点
    js重定向
    php obstart
    php保存远程图片
    php获取前天的昨天的日期
    weixin js接口
  • 原文地址:https://www.cnblogs.com/meetuj/p/15290986.html
Copyright © 2011-2022 走看看