tiandi2050 2015-08-03 08:55:17 21254次浏览 4条评论 32 4 0

插件安装的前提是把之前composer安装方法看懂,当然也要对Yii2有一定的了解:

实际上这些插件jq的形式网上都有,只是安装过后,用着比较方便罢了

1、Yii2中的redis:

命令:

php composer.phar require --prefer-dist yiisoft/yii2-redis

"yiisoft/yii2-redis": "~2.0.0"

配置文件:

return [
    //....
    'components' => [
        'redis' => [
            'class' => 'yii\redis\Connection',
            'hostname' => 'localhost',
            'port' => 6379,
            'database' => 0,
        ],
    ]
];

这个还需要深入的学习

2、DateTimePicker插件 日期格式:2015-07-01 11:25

命令:

php composer.phar require "2amigos/yii2-date-picker-widget" "*"

use dosamigos\datepicker\DatePicker;

1> 使用widget方式

<?= DatePicker::widget([
    'model' => $model,
    'attribute' => 'date',
    'template' => '{addon}{input}',
        'clientOptions' => [
            'autoclose' => true,
            'format' => 'dd-M-yyyy'
        ]
]);?>

2> ActiveForm方式

<?= $form->field($model, 'date')->widget(
    DatePicker::className(), [
        // inline too, not bad
        'inline' => true, 
        // modify template for custom rendering
        'template' => '<div class="well well-sm" style="background-color: #fff; width:250px">{input}</div>',
        'clientOptions' => [
            'autoclose' => true,
            'format' => 'dd-M-yyyy'
        ]
]);?>

4、yii2-date-range,这个是选择时间范围的一个插件 出现的格式:2015-07-31 - 2015-07-31

命令:

php composer.phar require kartik-v/yii2-date-range "*"

"kartik-v/yii2-date-range": "*"

用法参见网址:http://www.yiiframework.com/extension/yii2-bootstrap-daterangepicker/

简单的用法:

<?php echo DateRangePicker::widget([
    //  'model'=>$searchModel,
    'attribute'=>'created_range',
    'convertFormat'=>true,
    'pluginOptions'=>[
        'timePickerIncrement'=>30,
        'format'=>'Y-m-d'
    ]
]);?>

5、timepicki 插件 格式是 - 8:00 AM 、9:00 PM

$this->registerCssFile('@web/static/plugins/timepicki/timepicki.css');
$this->registerJsFile('@web/static/plugins/timepicki/timepicki.js', ['depends'=>'yii\web\JqueryAsset']);
$this->registerJs('$(".timepicki").timepicki();');

具体已经放在外边的插件压缩文件timepickier中

6、 Yii2 自带的时间插件 输出格式- 2015-07-03

要加上命名空间:use yii\jui\DatePicker;

具体参见:

http://stackoverflow.com/questions/27563120/how-to-add-yii2-jui-datepicker-to-filter-field-in-gridview
http://www.yiiframework.com/doc-2.0/yii-jui-datepicker.html

7、KindEditor for Yii2,这个是yii2的编辑器

命令:

$ php composer.phar require pjkui/kindeditor "dev-master" 
     
"pjkui/kindeditor": "dev-master"

用法参见网址:http://www.yiichina.com/extension/358

8、其他诸如:

以下的Yii2自带的组件:

yii\helpers\Html;                //html控件
yii\grid\GridView;              //分页控件
yii\helpers\Url;                  //链接地址控件
yii\widgets\DetailView;     //信息展示控件
yii\widgets\ActiveForm;    //表单控件

这几个组件的用法每一个都需要大量的篇幅去说,有时候两个结合,三个结合,四、五个同原生js、jq结合就能做出很好的效果

这里的控件每一个都需要出一个教程

还有很多插件,我还没用到,慢慢补充

觉得很赞
您需要登录后才可以评论。登录 | 立即注册