<script src="<?=Yii::$app->request->baseUrl?>/js/ckeditor/ckeditor.js"></script>
<textarea name="editor1" id="editor1" rows="10" cols="80"></textarea>
1 一定要在vue的created方法里面初始化ckeditor
created:function(){
Vue.nextTick(function () {
CKEDITOR.replace('editor1',{
height:350,
width:680,
});
});
},
2 插入短代码
insert_tag:function(myValue){
// Get the editor instance that we want to interact with.
var oEditor = CKEDITOR.instances.editor1;
// Check the active editing mode.
oEditor.insertText( myValue );
},
3 获取内容
var content = CKEDITOR.instances.editor1.getData();
4 设置内容
var content = CKEDITOR.instances.editor1.setData();