yii2basic下使用ueditor

来源:互联网 发布:联通是什么网络模式 编辑:程序博客网 时间:2024/04/30 00:24

1、下载ueditor,在yii2目录的web文件夹下新建的public文件夹,把ueditor放入public下
2、在view下新建ueditor.php文件

<?phpuse yii\helpers\Html;use yii\bootstrap\ActiveForm;/* @var $this yii\web\View引入相关js文件 */<?=Html::jsFile('@web/public/ueditor/ueditor.config.js')?><?=Html::jsFile('@web/public/ueditor/ueditor.all.min.js')?><?=Html::jsFile('@web/public/ueditor/lang/zh-cn/zh-cn.js')?><?php $form = ActiveForm::begin([    'id' => 'upload',    'enableAjaxValidation' => false,    'options' => ['enctype' => 'multipart/form-data']]);?><?= $form->field($model, 'content')->textarea(['rows' => 100, 'id' => 'editor', 'class' => 'col-sm-1 col-md-12']); ?><?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?><?php ActiveForm::end(); ?><script type="text/javascript">    window.onload=function(){            var ue = UE.getEditor('editor');//把ueditor实例化到textarea表单上,注意getEditor()参数为表单id      }</script>

3、

0 0
原创粉丝点击