1

私は、新しい Yii プロジェクトでYii-Bootstrapを使用しています。インストール手順に正確に従いました。

フロント ページでは、JS Carousel プラグインを使用しています。

$this->widget('bootstrap.widgets.TbCarousel', array(
    'items'=>array(
        array(
            'image'=>'http://placehold.it/770x400&text=First+thumbnail',
            'label'=>'asdf',
            'caption'=>'Cras justo odio, '
        ),
        array(
            'image'=>'http://placehold.it/770x400&text=Second+thumbnail',
            'label'=>'asdf',
            'caption'=>'Cras justo odio, '
        ),
        array(
            'image'=>'http://placehold.it/770x400&text=Third+thumbnail',
            'label'=>'asdf',
            'caption'=>'Cras justo odio, '
        ),
    ),
));

Uncaught TypeError: Object [object Object] has no method 'carousel'

これにより、.carousel()見つからないエラーが発生します。JSファイルが登録されていないようです。CSSとすべてがうまく見えます。

yii-environment 拡張機能を使用しています。

return array(

    // Set yiiPath (relative to Environment.php)
    'yiiPath' => dirname(__FILE__) . '/../../../yii-1.1.13/framework/yii.php',
    'yiicPath' => dirname(__FILE__) . '/../../../yii-1.1.13/framework/yiic.php',
    'yiitPath' => dirname(__FILE__) . '/../../../yii-1.1.13/framework/yiit.php',

    // Static function Yii::setPathOfAlias()
    'yiiSetPathOfAlias' => array(
        // uncomment the following to define a path alias
        'bootstrap' => realpath(dirname(__FILE__).'/../extensions/bootstrap')
    ),

    // This is the main Web application configuration. Any writable
    // CWebApplication properties can be configured here.
    'configWeb' => array(

        'basePath' => dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
            'theme' => 'bootstrap',

        // Preloading 'log' component
        'preload' => array('log'),

        // Autoloading model and component classes
        'import' => array(
            'application.models.*',
            'application.components.*',
        ),

        // Application components
        'components' => array(
            'bootstrap'=>array(
                'class'=>'bootstrap.components.Bootstrap',
            ),

助言がありますか?

4

2 に答える 2

4

css と js を具体的に登録する必要があります。

Yii::app()->bootstrap->register();

これは、拡張機能の古いバージョンで行われていた方法とは異なります。これがどこのドキュメントにも記載されていない理由がわかりません。

サイト/アプリ全体で yii-bootstrap を使用している場合、または特定のビューでのみ実行している場合は、それらのビューに配置することができます。

PS - この関数は、bootstrap/components/Bootstrap.phpファイルにあります。

于 2013-02-28T06:21:11.283 に答える