您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Yii 如何使用 Ueditor ?

2024/12/28 14:44:10发布20次查看
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}"
最后在视图中引入使用即可。
<?phpuse 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教程》
以上就是yii 如何使用 ueditor ?的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product