之前看了好多都没有特别好的答案,今天终于整出来了,超级简单
v-model="content"
ref="myQuillEditor"
@change="onEditorChange($event)">
class="avatar-uploader"
:action="serverUrl"
name="img"
:show-file-list="false"
:on-success="uploadSuccess"
:on-error="uploadError"
:before-upload="beforeUpload">
mounted() {
this.content = this.data;
this.$refs['myQuillEditor'].quill.getModule('toolbar').addHandler('image', function(value) {
if (value) {
const input = this.container.offsetParent.nextSibling.nextElementSibling.childNodes[0].childNodes[0];
input.click();
} else {
this.quill.format('image', false);
}
});
}
最重要的就是这句
const input = this.container.offsetParent.nextSibling.nextElementSibling.childNodes[0].childNodes[0];