Yii 如何使用 Ueditor ?

Yii 如何使用 Ueditor ?

Yii 如何使用 Ueditor ?

首先在入口文件目錄下新建public目錄和uploads目錄;

然后下載Ueditor,解壓到public目錄下;

接著引“ueditor for yii2”庫(kù),并定義自定義上傳目錄;

"imagePathFormat":?"/uploads/ueditor/image/{yyyy}{mm}{dd}/{time}{rand:6}",?? ?"scrawlPathFormat":?"/uploads/ueditor/image/{yyyy}{mm}{dd}/{time}{rand:6}"

最后在視圖中引入使用即可。

<?php use yiihelpersHtml; use yiibootstrapActiveForm; //引入百度編輯器 $this->registerJsFile('@web/public/ueditor/ueditor.config.js');//注冊(cè)自定義js $this-&gt;registerJsFile('@web/public/ueditor/ueditor.all.min.js'); $this-&gt;registerJsFile('@web/public/ueditor/lang/zh-cn/zh-cn.js'); ?&gt; <script>  $(function(){     var ue = UE.getEditor(&#39;editor&#39;);  }) </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([         &#39;id&#39;=>'upload', ????????'enableAjaxValidation'?=&gt;?false, ????????'options'=&gt;['enctype'=&gt;'multipart/form-data'] ????]); ?&gt; ????=?$form-&gt;field($model,'title')-&gt;textInput();?&gt; ????=?$form-&gt;field($model,?'image')-&gt;fileInput();?&gt; ????=?$form-&gt;field($model,'content')-&gt;textarea(['rows'=&gt;6,'id'=&gt;'editor','class'=&gt;'col-sm-1?col-md-12']);?&gt; ????=??Html::submitButton('提交',?['class'=&gt;'btn?btn-primary','name'?=&gt;'submit-button'])??&gt;  <?php  ActiveForm::end();?>

推薦教程:《Yii教程

? 版權(quán)聲明
THE END
喜歡就支持一下吧
點(diǎn)贊14 分享