九、uniapp的editor编辑器
editor
1、调用初始化的方法,目的是创建editor组件对应的 editorContext (实例上下文)
@ready="onEditorReady"
onEditorReady() {
uni.createSelectorQuery().select('#editor').context((res) => {
this.editorCtx = res.context
}).exec()
}
2、创建editorContext (实例上下文): `this.editorCtx = res.context`之后就可以用来操作 `editor` 内容了
列如:上传图片到editor上
insertImage() {
uni.chooseImage({
success:(res)=>{
console.log('选择图片成功')
console.log(res)
this.editorCtx.insertImage({
width: '100%',
height: '20%',
src: res.tempFilePaths[0]
})
}
})
},
列如:撤销editor上的内容
undo() {
this.editorCtx.undo()
},