您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
这篇文章给大家分享的是有关Yii使用Ueditor的方法的内容。小编觉得挺实用的,因此分享给大家做个参考。一起跟随小编过来看看吧。
Yii 如何使用 Ueditor ?
首先在入口文件目录下新建public目录和uploads目录;
然后下载Ueditor,解压到public目录下;
接着引“ueditor for yii2”库,并定义自定义上传目录;
"imagePathFormat": "/uploads/ueditor/image/{yyyy}{mm}{dd}/{time}{rand:6}", "scrawlPathFormat": "/uploads/ueditor/image/{yyyy}{mm}{dd}/{time}{rand:6}"
最后在视图中引入使用即可。
<?php use yii\helpers\Html; use yii\bootstrap\ActiveForm; //引入百度编辑器 $this->registerJsFile('@web/public/ueditor/ueditor.config.js');//注册自定义js $this->registerJsFile('@web/public/ueditor/ueditor.all.min.js'); $this->registerJsFile('@web/public/ueditor/lang/zh-cn/zh-cn.js'); ?> <script> $(function(){ var ue = UE.getEditor('editor'); }) </script> <style> .inline .radio,.inline .checkbox{display: inline-block;margin: 0 5px;} #editor{margin-top: 20px;padding:0;margin:20px 0;width:100%;height:auto;border: none;} </style> <?php $form=ActiveForm::begin([ 'id'=>'upload', 'enableAjaxValidation' => false, 'options'=>['enctype'=>'multipart/form-data'] ]); ?> <?= $form->field($model,'title')->textInput();?> <?= $form->field($model, 'image')->fileInput();?> <?= $form->field($model,'content')->textarea(['rows'=>6,'id'=>'editor','class'=>'col-sm-1 col-md-12']);?> <?= Html::submitButton('提交', ['class'=>'btn btn-primary','name' =>'submit-button']) ?> <?php ActiveForm::end();?>
感谢各位的阅读!关于Yii使用Ueditor的方法就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到吧!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。